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

MouseArea inside MapPolygon treats enter/leave events and click events differently

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.14.1
    • Fix Version/s: None
    • Component/s: Location
    • Labels:
      None
    • Environment:
      Linux 64-bit
    • Platform/s:
      Linux/X11

      Description

      If one set a MouseArea inside MapPolygon (that is not a rectangle shape) and check mouse events, it will find that click events are respecting polygon shape and enter/leave events are not. Actually, enter/leave events fire in respect of the minimal rectangle that covers all points of polygon.

      Here some minimal reproducing snippet:

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Controls.Material 2.12
      import QtQuick.Window 2.12
      import QtLocation 5.12
      import QtPositioning 5.12
      
      Window {
          id: window
          width: 800
          height: 600    
          Map {
              plugin: Plugin { name: "osm" }        
              anchors.fill: parent
              zoomLevel: 8.0
              center: QtPositioning.coordinate(60.0, 30.0)        
              MapPolygon {
                  id: poly
                  property bool hovered: false
                  property bool selected: false
                  color: {
                      if (hovered && selected)
                          return Material.color(Material.Yellow, Material.Shade300)
                      else if(hovered)
                          return Material.color(Material.Red, Material.Shade300)
                      else if(selected)
                          return Material.color(Material.Yellow)
                      else
                          return Material.color(Material.Red)
                  }            
                  path: [
                      { latitude: 60.5, longitude: 30 },
                      { latitude: 59.5, longitude: 30 },
                      { latitude: 60, longitude: 30.5 }
                  ]            
                  MouseArea {
                      id: ma
                      anchors.fill: parent
                      hoverEnabled: true
                      onEntered: { poly.hovered = true }
                      onExited: { poly.hovered = false }
                      onClicked: { poly.selected = !poly.selected }
                  }
              }
          }
      }
      
      

        Attachments

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

          Activity

            People

            Assignee:
            paangele Paolo Angelelli
            Reporter:
            gennadykazachek Gennady Kazachek
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes