QML how to call Shift+Tab behavior without using keyboard?
-
wrote on 17 Sept 2024, 09:40 last edited by
I have an embedded linux device with only 5 keys mapped in system as keyboard emiting keyboard events:
1 - TAB
2 - SPACE
3 - UP
4 - DOWN
5 - ESC
It is enough to edit parameters - many SpinBoxes with focus change with TAB. But the client wants to have an option to focus back just like on desktop by pressing Shift + Tab, but by pressing SPACE on Spinbox
How to do that in QML?Got something like:
function navBack(repeater,model) { let prevItem = repeater.itemAt(model.index-1) if(prevItem) prevItem.forceActiveFocus() } SpinBox { Keys.onSpacePressed: { navBack(repeater,model); event.accepted = true }
And it works inside repeater, but I am unable to focus Back previous editable element like by pressing Shift+TAB
Which function is called on Shift+TAB key combination? And how to call it? -
Item has a
nextItemInFocusChain(bool forward = true)
function.You could do
Keys.onSpacePressed: event => { const previousItem = nextItemInFocusChain(false); if (previousItem) previousItem.forceActiveFocus(); event.accepted = true; }
EDIT: that could also be done at the window level with a shortcut or an event filter to not have to modify each item.
-
wrote on 19 Sept 2024, 05:17 last edited by
It worked perfectly! Thank you
1/3