Skip to content

Commit dd67e9e

Browse files
committed
fix(ComboBox): fix highlight lingering after mouse leaves
- Track the popup's hover state by adding a isInteractingWithContent property, and modify the highlighted property in the delegate. - The logic of the highlighted property now depends on isInteractingWithContent, automatically clearing the highlight when the mouse leaves. 修复鼠标移出后高亮项仍然残留的问题 - 通过添加isInteractingWithContent属性跟踪popup悬停状态,修改delegate的highlighted - highlighted 属性逻辑依赖isInteractingWithContent,鼠标离开时自动清除高亮 Log: 修复ComboBox的菜单项鼠标离开后高亮残留问题 Influence: ComboBox菜单项 PMS: BUG-304991
1 parent 1998e42 commit dd67e9e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

qt6/src/qml/ComboBox.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ T.ComboBox {
3636
useIndicatorPadding: true
3737
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : (model[control.textRole] === undefined ? modelData[control.textRole] : model[control.textRole])) : modelData
3838
icon.name: (control.iconNameRole && model[control.iconNameRole] !== undefined) ? model[control.iconNameRole] : null
39-
highlighted: control.highlightedIndex === index
39+
highlighted: popup.isInteractingWithContent ? control.highlightedIndex === index : false
4040
hoverEnabled: control.hoverEnabled
4141
autoExclusive: true
4242
checked: control.currentIndex === index
@@ -169,6 +169,18 @@ T.ComboBox {
169169
rightMargin: DS.Style.popup.margin
170170
palette: control.palette
171171
implicitWidth: control.flat ? Math.max(contentItem.implicitWidth, control.width) : control.width
172+
property bool isInteractingWithContent: false
173+
onClosed: isInteractingWithContent = false
174+
Connections {
175+
target: control
176+
function onHighlightedIndexChanged() {
177+
if (control.highlightedIndex >= 0)
178+
popup.isInteractingWithContent = true
179+
}
180+
}
181+
HoverHandler {
182+
onHoveredChanged: popup.isInteractingWithContent = hovered
183+
}
172184
contentItem: ArrowListView {
173185
clip: true
174186
maxVisibleItems: control.maxVisibleItems

0 commit comments

Comments
 (0)