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

TapHandler fires for all overlapping items

    XMLWordPrintable

Details

    • a6e196ce9 (dev), ae7069bfa (6.5), dd3484343 (6.5.0), b0bb5823e (6.4), a8fb5c36c (tqtc/lts-6.2)

    Description

      When multiple (map)items are overlapping, and have tap handlers inside, clicking on one will make all of them fire

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtLocation 5.12
      import QtPositioning 5.5
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Map {
              anchors.fill: parent
              plugin: Plugin { name: "osm" }
              zoomLevel: 4.3
              center: QtPositioning.coordinate(19.5,19.5)
              MapQuickItem {
                  sourceItem: Rectangle {
                      id: rct
                      width: 48
                      height: 48
                      color: "firebrick"
      //                    MouseArea { // works
      //                        anchors.fill: parent
      //                        onPressed: console.log("pressed")
      //                        onReleased: console.log("released")
      //                    }
                      TapHandler { // doesnt work
                          onPressedChanged: {
                              if (pressed)
                                  console.log("pressed")
                              else
                                  console.log("released")
                          }
                      }
                  }
                  coordinate: QtPositioning.coordinate(20, 20)
                  anchorPoint.x: rct.width/2
                  anchorPoint.y: rct.height
              }
      
              MapQuickItem {
                  sourceItem: Rectangle {
                      id: rct2
                      width: 48
                      height: 48
                      color: "firebrick"
      //                    MouseArea { // works
      //                        anchors.fill: parent
      //                        onPressed: console.log("pressed")
      //                        onReleased: console.log("released")
      //                    }
                      TapHandler { // doesnt work
                          onPressedChanged: {
                              if (pressed)
                                  console.log("pressed2")
                              else
                                  console.log("released2")
                          }
                      }
                  }
                  coordinate: QtPositioning.coordinate(19, 19)
                  anchorPoint.x: rct2.width/2
                  anchorPoint.y: rct2.height
              }
          }
      }
      
      

      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
              paangele Paolo Angelelli
              Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated: