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

Keys.forwardTo regression in QtQuick 2.0: an unaccepted key after a forwardTo is sent to the parent item before the current item

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.3.0 RC1
    • 5.2.1
    • None
    • Qt 5.2.1 - Windows 7
    • qtdeclarative: 8da17239ed4a68270c74f6a5e5ca04d82d99b547

    Description

      As mentionned in http://qt-project.org/doc/qt-5/qml-qtquick-keys.html,

      If priority is Keys.BeforeItem (default) the order of key event processing is:
      Items specified in forwardTo
      specific key handlers, e.g. onReturnPressed
      onPressed, onReleased handlers
      Item specific key handling, e.g. TextInput key handling
      parent item

      There is a regression in QtQuick 2.0 with the following code:

      import QtQuick 2.0
      
      Rectangle {
          width: 360
          height: 360
          Keys.onPressed: console.log("Rectangle: onPressed="+event.key);
          Keys.onReturnPressed: console.log("Rectangle: onReturnPressed="+event.key);
          Text {
              focus: true
              Keys.forwardTo: [myItem]
              anchors.centerIn: parent
              text: "Hello World"
              Keys.onPressed: console.log("Text: onPressed="+event.key);
              Keys.onReturnPressed: console.log("Text: onReturnPressed="+event.key);
              Item {
                  id: myItem
                  Keys.onPressed: console.log("Item: onPressed="+event.key);
              }
          }
      }
      

      If I press the 'u' key, then 'Return' key, here is the log:

      Item: onPressed=85
      Rectangle: onPressed=85
      Text: onPressed=85
      Rectangle: onPressed=85
      Item: onPressed=16777220
      Rectangle: onReturnPressed=16777220
      

      We can see that after sending the keypress to the Item, it should be sent to the Text element, but it is sent to the Rectangle, then Text, then again Rectangle.

      The same applies for the 'Return' key.

      The same code works fine with "import QtQuick 1.0" and qmlviewer.

      Attachments

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

        Activity

          People

            aalpert Alan Alpert
            agroyer Anthony Groyer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes