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

Closing Popup with escape key does not close the expected popup

    XMLWordPrintable

Details

    • Shovelling Snow, Q1/2020 Finale, Q2/2020 kick off

    Description

      With multiple popups open, pressing escape will close the top one, not the one that has the active focus.

      With attached example:

      • press "Show dialog1"
      • press "Show dialog2"
      • press dialog1 so that it get active focus
      • press esc

      -> it closes the dialog2 instead of 1

      import QtQuick 2.12
      import QtQuick.Controls 2.5
      import QtQuick.Window 2.12
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("QTBUG-79280")
          objectName: "appwin"
      
          onActiveFocusItemChanged: console.log("activeFocusItem", activeFocusItem)
      
          Row {
              spacing: 20        
              Button {
                  text: "Show Dialog1"
                  objectName: "button1"
                  onClicked: dialog1.open()
              }
      
              Button {
                  text: "Show Dialog2"
                  objectName: "button2"
                  onClicked: dialog2.open()
              }
          }
      
          Dialog {
              id: dialog1
              objectName: "dialog1"
              title: "Dialog1"
              x: 200
              y: 100
              width: 200
              height: 200
              focus: true
              closePolicy: Popup.CloseOnEscape | Popup.NoAutoClose
              MouseArea {
                  onClicked: forceActiveFocus()
                  objectName: "MouseArea1"
                  focus: true
                  width: 200
                  height: 200
                  Text {
                      text: parent.activeFocus ? "has active focus" : ""
                  }
      
                  Keys.onPressed: function(event) { console.log("dialog1 key pressed 0x" + event.key.toString(16)) }
              }
          }
      
          Dialog {
              id: dialog2
              title: "Dialog2"
              objectName: "dialog2"
              x: 100
              y: 200
              width: 200
              height: 200
              focus: true
              closePolicy: Popup.CloseOnEscape | Popup.NoAutoClose
              MouseArea {
                  objectName: "MouseArea2"
                  onClicked: forceActiveFocus()
                  width: 200
                  height: 200
                  Text {
                      text: parent.activeFocus ? "has active focus" : ""
                  }
                  focus: true
                  Keys.onPressed: function(event) { console.log("dialog2 key pressed 0x" + event.key.toString(16)) }
              }
          }
      }
      

      Attachments

        1. qtbug79280_log.txt
          3 kB
        2. qtbug79280_qqc_diag.diff
          4 kB
        3. qtbug79280_qtbase_diag.diff
          4 kB
        4. qtbug79280.tar.gz
          1 kB
        5. qtbug79280.zip
          2 kB
        6. qtbug79280-mitch-debug-output.txt
          6 kB

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              poikelin Joni Poikelin
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes