Commit e136cd3
committed
fix(ComboBox): fix the issue of highlighted state lingering after
mouse leaves menu items
Root cause: The delegate.highlighted is bound to
control.highlightedIndex (read-only).
When the mouse leaves the popup area, this value is not automatically
reset, causing the highlighted state to persist.
Fix approach:
- Add a new contentHovered property to the popup to track whether
the mouse is within the popup list area
- Use HoverHandler in Qt6 to synchronize the contentHovered state
- Use MouseArea (acceptedButtons: Qt.NoButton) in Qt5 to synchronize
the contentHovered state
- Change delegate.highlighted to popup.contentHovered &&
control.highlightedIndex === index
Log: Fixed the issue of lingering highlight on ComboBox menu items after mouse leaves
Influence: ComboBox menu items
fix(ComboBox): 修复菜单项鼠标离开后高亮残留问题
根因:delegate.highlighted 绑定 control.highlightedIndex(只读),
鼠标离开弹出区域时该值不会自动重置,导致高亮状态持续残留。
修复方案:
- 为 popup 新增 contentHovered 属性,追踪鼠标是否在弹出列表区域内
- Qt6 版本使用 HoverHandler 同步 contentHovered 状态
- Qt5 版本使用 MouseArea(acceptedButtons: Qt.NoButton)同步 contentHovered 状态
- 将 delegate.highlighted 改为 popup.contentHovered && control.highlightedIndex === index
Log: 修复ComboBox的菜单项鼠标离开后高亮残留问题
Influence: ComboBox菜单项
PMS: BUG-3066831 parent 1998e42 commit e136cd3
2 files changed
Lines changed: 15 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
179 | 183 | | |
180 | 184 | | |
181 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
149 | 150 | | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
157 | 165 | | |
158 | 166 | | |
159 | 167 | | |
| |||
0 commit comments