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

Cannot "capture" events from certain QtQuickControls

    XMLWordPrintable

Details

    Description

      https://codereview.qt-project.org/#change,76134 added Keys.forwardTo in several controls.

      Previously,

      TextField {
        Keys.onPressed: {
          event.accepted = true;
        }
      }
      

      would let all text/other inputs that TextInput accepted be handled by the TextInput inside of TextField, and any other events would be accepted by the TextField's Keys.onPressed handler.

      With the change, the above code now causes all events to be accepted by the Keys.onPressed handler before the TextInput can handle them.

      Here's an example of a useful case that no longer works:

      Item {
        Keys.onPressed: {
          if (event.key == Qt.Key_Up || event.key == Qt.Key_Down) {
          // Do something with key up and key down, but not if the TextField
          // has active focus
          }
        }
      
        TextField {
          Keys.onPressed: {
            event.accepted = true;
          }
        }
      }
      

      Attachments

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

        Activity

          People

            daiweili Daiwei Li
            daiweili Daiwei Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes