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

TapHandler catches tap event below modal popup

    XMLWordPrintable

Details

    • macOS

    Description

      If a TapHandler is defined in a modal popup, and on the same coordinates another TapHandler is defined (not part of the modal popup but main window) after the tap event from the modal is emited, the TapHandler below the modal will catch the tap event aswell.

      I have a code example and video that clarify the issue.

      Video explanation: The blue box is only changing colors if it is clicked. The green box from the modal popup is only closing the popup. But as you can see from the video, after pressing the green button that closes the popup, the blue box changes color (which means it was pressed aswell at the same time)

      import QtQuick
      import QtQuick.Window
      import QtQuick.ControlsWindow {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")    Popup {
              id: popup
              modal: true
              dim: true
              height: 200
              width: 200        x: window.width / 2 - width / 2
              y: window.height / 2 - height / 2        contentItem: Item {
                  Rectangle {
                      anchors.centerIn: parent
                      height: 50
                      width: 50
                      color: "green"                TapHandler {
                          onTapped: popup.close()
                      }
                  }
              }
          }    Rectangle {
              id: mainRect        property bool isRed: false        anchors.centerIn: parent
              height: 100
              width: 100        color: mainRect.isRed ? "red" : "blue"        TapHandler {
                  onTapped: mainRect.isRed = !mainRect.isRed
              }
          }    Button {
              anchors.bottom: window.bottom
              text: "Open popup"
              onClicked: popup.open()
          }
      } 

      Screen Recording 2024-04-10 at 11.48.26.mov

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              markostanke Marko Stanojevic
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes