[ComboBox] Follow focusPolicy
ClosedPublic

Authored by broulik on Oct 23 2019, 7:20 AM.

Details

Summary

Since we have a MouseArea in our contentItem stealing events from the underlying Control, its focusPolicy (defaults to Qt.StrongFocus for ComboBox) is never followed.
This causes the ComboBox not to get focused when clicking it, making it impossible to use the arrow keys to navigate it.

Test Plan
  • It now behaves like a widget QComboBox. Clicked it, could use arrow keys to navigate the popup
  • Is highlighted blue with focus like a widget QComboBox afterwards

Diff Detail

Repository
R858 Qt Quick Controls 2: Desktop Style
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Oct 23 2019, 7:20 AM
Restricted Application added a project: Plasma. · View Herald TranscriptOct 23 2019, 7:20 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Oct 23 2019, 7:20 AM
apol added a subscriber: apol.Oct 23 2019, 11:55 AM

Wouldn't it make more sense to not accept the event then?

org.kde.desktop/ComboBox.qml
79 ↗(On Diff #68586)

if (controlRoot.focusPolicy & Qt.ClickFocus) { should be enough.

In D24879#552657, @apol wrote:

Wouldn't it make more sense to not accept the event then?

Not sure. The main reason for the MouseArea (apart from wheel handling) seems to be opening the ComboBox on *press*. The default implementation opens on click, so we do need to accept the event to keep the original implementation from interfering with that.
I just tried mouse.accepted = false at the end but that causes some strange side-effects, like not being able to open the combo box a second time, so I wouldn't want to risk it.

mart accepted this revision.Nov 4 2019, 10:39 AM
This revision is now accepted and ready to land.Nov 4 2019, 10:39 AM
mart added a comment.Nov 4 2019, 10:41 AM

one thing that may be tried is to use input handlers instead of the mousearea to manage the wheel (tough i am not sure we can already use them in frameworks due to qt version requirements)

This revision was automatically updated to reflect the committed changes.