Dynamic tab navigation out of TextArea
-
I'm trying to allow users to dynamically set the tab order by dynamically setting
item.KeyNavigation.tab
as:function setTab(fromStr, toStr) { const from = getInput(fromStr); const to = getInput(toStr); from.KeyNavigation.tab = to; }
Where
getInput
identifies the input field based on the user configuration file:function getInput(inputStr) { let input = nulll; switch (inputStr) { case "username": input = userFields.usernameInput; break; ... }
This works well for all items except TextArea, where the tab key is captured by default. I've tried a variety of solutions I've found, and all of them result in tab moving to the next field in order on the form, not according to what I'm setting
KeyNavigation.tab
to. This seems to be true even when I hard codeKeyNavigation.tab
to a field other than the next one in the order of the form.For example, adding this to the TextArea results in tab going to the next field (third), not the field I'm specifically tell it to go to (first):
TextField { id: first } TextArea { id: second KeyNavigation.priority: KeyNavigation.BeforeItem // this doesn't matter Keys.onTabPressed: { event.accepted = true; // this doesn't matter first.forceActiveFocus(); } } TextField { id: third }
What I want to work is:
TextArea { id: second Keys.onTabPressed: { let nextItem = nextItemInFocusChain(true); nextItem.forceActiveFocus() } }
Where I've dynamically set the next item from "second" to be "first". No matter what I've tried, tab in the TextArea is either absorbed by the TextArea, or focus moves to the next item in the dialog (three), not the item I've told it I want it to go to (first).
Ideas?
QT 5.1.15, QTQuick.Controls 2.15