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

Popup's CloseOnEscape policy prevents escape key from being used without closing the popup

    XMLWordPrintable

Details

    • c4eefa4a8d6d3e95062deb78229940460a7ef605

    Description

      I have a shortcut "editor" item in a popup. When editing a shortcut, the item has focus, as it needs to process the key events. If the user wants to abort editing of the shortcut, they should be able to press escape to do so. The problem is that Popup grabs the escape shortcut, so that the popup always closes on the first escape press, instead of the second:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.1
      
      Window {
          id: window
          visible: true
          width: 400
          height: 400
      
          Popup {
              id: popup
              width: 400
              height: 400
      
              contentItem: Rectangle {
                  id: keySequenceEditor
                  focus: true
                  color: "salmon"
      
                  Keys.onEscapePressed: {
                      focus = false
                      // Popup shouldn't close
                      event.accepted = true
                  }
              }
          }
      
          Button {
              objectName: "Button"
              text: "open"
              onClicked: popup.open()
          }
      }
      

      This is probably caused by b31b4094e1728d839fef30f5128c81451ea75e4a, so I'd imagine it's an issue in 5.7 as well.

      Attachments

        For Gerrit Dashboard: QTBUG-57098
        # Subject Branch Project Status CR V

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes