Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.9, 6.5.0
-
None
Description
Problem
KeyNavigation attached property, when used on a parent AND child item to redirect focus FROM parent TO child, whenever a child is focused it would accept subsequent key presses in that direction. This is bad because active focus does not change, but it doesn't let us react to the key press (e.g. animating that active focus hits the bounds).
What actually happens is that a focused child item receives the arrow key press, but since it doesn't have any item for that direction, event bubbles up to the parent item, which does specify a KeyNavigation is that direction and its target is the same child item. So, parent handles the key press and forces focus onto an already focused item. Nothing visually changes, but we didn't get to handle the key press at the top-most level item (window's contentItem).
Solution
The first and most obvious solution is to alter the KeyNavigation algorithm to check whether the new to-be-focused Item is literally the same object as the current active focused one. And if so, stop processing and don't accept the event.
Additional Information
Note about attachment: Kirigami is not strictly needed, but helps visualizing active focus target. It is written with KF6 in mind (using newer JavaScript syntax than what's available in Qt 5), but can be easily ported back to KF5, or removed completely. Visualizing active focus is mostly useful in combination with another feature: play certain animations when key navigation hits the bounds.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-113669 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
482196,1 | KeyNavigation: Don't accept event if focused item did not change | dev | qt/qtdeclarative | Status: NEW | -1 | 0 |