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

Disabled MenuItem propagates clicks to underlying mouse area in drawer

    XMLWordPrintable

Details

    • Windows
    • 9d3488b3c (dev), 427e7ac9d (6.8), 9fd43c27d (dev), a5a54c083 (6.8), b55991793 (tqtc/lts-6.5), 4a55dde38 (dev), 3537f7450 (6.8)

    Description

      NOTE!

      Similar bug exists ( QTBUG-106563 ) but this is not a duplicate as the example application from that bug works correctly with 6.5.6 and 6.8.0, whereas the application provided here does not.

      Description:

      In the attached application, open the Drawer, click on button to open the context menu and then click on the second (disabled) MenuItem. The item in underlying list view catches the click, not the menu item.

      The problem seems to be related to the fact that the menu is in a Drawer. The problem was not seen in context menus outside the drawer. 

      pragma ComponentBehavior: Bound
      
      import QtQuick
      import QtQuick.Controls
      
      Window {
          id: _mainWindow
          width: 640
          height: 480
          visible: true
          title: qsTr("Click The Context Menu")
          Button {
              anchors.centerIn: parent
              text: "Click to open drawer"
              onClicked: _drawer.open()
          }
      
          Drawer {
              id: _drawer
              edge: Qt.RightEdge
              width: _mainWindow.width / 3
              height: _mainWindow.height
              Rectangle {
                  id: _flickableContent
                  color: "white"
                  height: parent.height
                  width: _drawer.width
                  Button {
                      id: _popupOpenButton
                      property int clicks: 0
                      anchors.horizontalCenter: parent.horizontalCenter
                      anchors.top: parent.top
                      anchors.topMargin: 5
                      text: qsTr("Click to open context menu (%1)").arg(clicks)
                      onClicked: {
                          clicks = 0
                          _popup.open()
                      }
                      Menu {
                          id: _popup
                          x: 0
                          y: _popupOpenButton.implicitHeight
                          width: parent.width - 10
                          MenuItem {
                              text: "Menu first"
                              onTriggered: _popupOpenButton.clicks += 10
                          }
                          MenuItem {
                              text: "Click me"
                              enabled: false
                              onTriggered: _popupOpenButton.clicks += 20
                          }
                          MenuItem {
                              text: "Menu third"
                              onTriggered: _popupOpenButton.clicks += 30
                          }
                      }
                  }
                  ListView {
                      anchors.top: _popupOpenButton.bottom
                      anchors.topMargin: 5
                      anchors.left: parent.left
                      anchors.right: parent.right
                      anchors.bottom: parent.bottom
                      model: ["first", "second", "third"]
                      delegate: Rectangle {
                          color: _mouseArea.containsMouse ? "lightgray" : "white"
                          width: parent.width - 10
                          height: 25
                          border.width: 1
                          border.color: "black"
                          anchors.horizontalCenter: parent.horizontalCenter
                          required property var model
                          required property int index
                          Label {
                              anchors.centerIn: parent
                              text: model.modelData
                          }
                          MouseArea {
                              id: _mouseArea
                              hoverEnabled: true
                              anchors.fill: parent
                              onPressed: _popupOpenButton.clicks += (index + 1)
                          }
                      }
                  }
              }
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              santhoshkumar Santhosh Kumar Selvaraj
              ottoryynanen Otto Ryynänen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: