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

Mousearea forwards events when disabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.1
    • None

    Description

      A disabled Mousearea forwards mouse events to the 'background'.
      this is troublesome for me in many cases right now.

      for example when i have a button that sits on top of a map-view.
      the map view accepts doubleclick to maximize/unmaximize or zoom.
      the button is sometimes disabled. and when it is disabled and the user still tries to click/tap on it multiple times, the action of the underlying element will be executed (in this case maximizing the view or zooming)

      it would be desireable that the mouse area still catches and consumes these events without triggering the action when disabled.

      right now i have to implement a second enabled property that replicates the buildin enabled property except for the mouse area.
      this is especially difficult for the QtQuick controls 2 switch.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          visible: true
          width: 400
          height: 400
          title: "qtbug69696"
      
          MouseArea {
              anchors.fill: parent
              onDoubleClicked: print("double clicked")
      
              Rectangle {
                  anchors.fill: parent
                  color: "tomato"
                  opacity: 0.4
              }
      
              MouseArea {
                  enabled: false
                  anchors.fill: parent
                  anchors.margins: 100
      
                  Rectangle {
                      anchors.fill: parent
                      color: "steelblue"
                  }
      
                  Text {
                      text: "Double-clicking in this square should not result in anything being printed"
                      color: "white"
                      fontSizeMode: Text.Fit
                      wrapMode: Text.Wrap
                      anchors.fill: parent
                      anchors.margins: 20
                  }
              }
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              smenzel Stefan Menzel
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes