Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dynamic tab navigation out of TextArea
Forum Updated to NodeBB v4.3 + New Features

Dynamic tab navigation out of TextArea

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 112 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cswingle
    wrote on last edited by
    #1

    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 code KeyNavigation.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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved