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

[Menu] dim property affects mouse events propagations, but it shouldn't

    XMLWordPrintable

Details

    • macOS, Windows

    Description

      dim property affects mouse events propagations but it shouldn't

      Sample code:

      import QtQuick
      import QtQuick.Controls
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Menu {
              id: contextMenu
              MenuItem { text: "Cut" }
              MenuItem { text: "Copy" }
              MenuItem { text: "Paste" }
              modal: true
              dim: false // this affects mouse events propagation, but it shouldn't
          }
      
          Rectangle {
              id: r
              anchors.fill: parent
              TapHandler {
                  acceptedButtons: Qt.LeftButton | Qt.RightButton
                  onTapped: (event, button) => {
                      if (button === Qt.LeftButton)
                         r.color = Qt.rgba(Math.random(1), Math.random(1), Math.random(1), 1)
                      else
                          contextMenu.popup()
                  }
              }
          }
      }
      

      Steps to reproduce:
      1. build and run sample
      2. click right button - menu is opened
      3. click left button outside menu - menu is closed, but click is also propagated to underlying item

      Pay attention that modal is set to true for the Menu, so according to documentation https://doc.qt.io/qt-6/qml-qtquick-controls2-popup.html#modal-prop it shouldn't propagate mouse events to underlying items.

      Modal popups often have a distinctive background dimming effect defined in Overlay.modal, and do not allow press or release events through to items beneath them. For example, if the user accidentally clicks outside of a popup, any item beneath that popup at the location of the click will not receive the event.

      But if user wants modal Menu without background dimming effect, and forces dim property to false, mouse events start propagating, but they shouldn't as Menu is modal.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              studiosus Vladimir Belyavsky
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes