Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38124

Keys.forwardTo elements do not get priority in key event handling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.4.0
    • 5.0.2
    • None
    • Linux x86_64

    Description

      When given a list of elements in Keys.forwardTo, any parent elements get to handle key events before the second element in this forward list. One would expect the forward list to have priority in key event handling.

      Below is an example to reproduce the issue.

      • Expected output on key press:
        FIRST HANDLER
        SECOND HANDLER
        PARENT HANDLER
      • Actual output on key press:
        FIRST HANDLER
        PARENT HANDLER
        SECOND HANDLER
        PARENT HANDLER
        PARENT HANDLER
      import QtQuick 2.0
      
      Rectangle {
          width: 360
          height: 360
      
          Rectangle {
              id: container
              focus: true
              anchors.fill: parent
      
              Rectangle {
                  id: rect1
                  color: "green"
                  height: parent.height / 2
                  anchors {
                      top: parent.top
                      left: parent.left
                      right: parent.right
                  }
      
                  Keys.onPressed: console.log("FIRST HANDLER")
              }
      
              Rectangle {
                  id: rect2
                  color: "olive"
                  anchors {
                      top: rect1.bottom
                      left: parent.left
                      right: parent.right
                      bottom: parent.bottom
                  }
      
                  Keys.onPressed: console.log("SECOND HANDLER")
              }
      
              Keys.forwardTo: [rect1, rect2]
          }
      
          Keys.onPressed: console.log("PARENT HANDLER")
      
          Component.onCompleted: container.forceActiveFocus()
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            liaqi Liang Qi
            anttip Antti Poikela
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes