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

Closing a menu will send the press event to items below it

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Invalid
    • Affects Version/s: 5.7
    • Fix Version/s: None
    • Component/s: Quick: Controls 2
    • Labels:
      None

      Description

      In the application below, clicking outside of the menu shouldn't send mouse events to items below the menu, but it does. For some reason, Qt Creator has the same behaviour, so it seems it's the same in widgets. However, if you think about an application like MS Paint, it's not acceptable for the canvas to receive press events at the same time as a menu was closed, because it would result in unintentional brush strokes, for example.

      import QtQuick 2.6
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          width: 300
          height: 300
          visible: true
      
          MouseArea {
              anchors.fill: parent
              onPressed: print("Oops!")
          }
      
          Menu {
              id: menu
              visible: true
      
              MenuItem {
                  text: "Blah"
              }
              MenuItem {
                  text: "Blah"
              }
              MenuItem {
                  text: "Blah"
              }
          }
      }
      

      I believe that this is also what causes the following to happen:

      That's with code similar to this:

      ToolButton {
          id: fileToolButton
          text: qsTr("File")
          onClicked: fileMenu.open()
      
          Menu {
              id: fileMenu
              y: fileToolButton.height
      
              MenuItem {
                  text: qsTr("New")
              }
          }
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            laknoll Lars Knoll
            Reporter:
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes