Skip to content

Commit 7766bca

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 - 属性逻辑依赖isInteractingWithContent,鼠标离开时自动清除高亮 Log: 修复ComboBox的菜单项鼠标离开后高亮残留问题 Influence: ComboBox菜单项 PMS: BUG-304991
1 parent 1998e42 commit 7766bca

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,13 +169,25 @@ 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+
}
172181
contentItem: ArrowListView {
173182
clip: true
174183
maxVisibleItems: control.maxVisibleItems
175184
view.model: control.delegateModel
176185
view.currentIndex: control.highlightedIndex
177186
view.highlightRangeMode: ListView.ApplyRange
178187
view.highlightMoveDuration: 0
188+
HoverHandler {
189+
onHoveredChanged: popup.isInteractingWithContent = hovered
190+
}
179191
}
180192

181193
background: FloatingPanel {

0 commit comments

Comments
 (0)