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

No signal emitted for menu closed or menu dismissal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • Some future release
    • 5.2.1, 5.3.0
    • Quick: Controls 1
    • None
    • Windows 7 MSVC2012 OpenGL 32bit

    Description

      There doesn't seem to be any way to detect the menu dismissal; that is, when user clicks anywhere else on the UI to close the menu pop.

      • The "visible" or "enabled" properties don't change when the "Menu" object is opened through "menuObj.pop()" function
      • Using signals from "MouseArea" or focus changing signals don't seem to allow this either
      • Qt Creator allows auto completion of this "on__menuClosed" signal but that seems to be private only (i.e. when run, the QML interpreter can't find it).
      • Adding some test code, for reference, in case it helps
      import QtQuick 2.0
      import QtQuick.Controls 1.1
      
      
      Rectangle {
          width: 600
          height: 600
      
          Rectangle {
              id: clickableRect
              focus: true
      
              color: "red"
              width: 300
              height: 300
              anchors.centerIn: parent
      
              ExclusiveGroup {
                  id: myGroup
              }
      
              Menu {
                  id: myMenu
      
                  onVisibleChanged: {
                      console.log("myMenu : onVisibleChanged");
                  }
                  onEnabledChanged: {
                      console.log("myMenu : onEnabledChanged");
                  }
      
                  //            on__menuClosed: { // <---- This appears to be a private signal but Qt Creator still allows me to auto complete this signal handler. However, runtime doesn't allow execution.
                  // It says "Cannot assign to non-existent property "on__menuClosed"
                  //                console.log("myMenu : on__menuClosed");
                  //            }
      
                  MenuItem {
                      text: "item 0"
                      checkable: true
                      exclusiveGroup: myGroup
      
                      onTriggered: {
                          console.log(" item0 - onTriggered - This selection works of course - but dismissal doesn't");
                      }
                  } // MenuItem
      
                  MenuItem {
                      text: "item 1"
                      checkable: true
                      exclusiveGroup: myGroup
                  } // MenuItem
      
      
              } // Menu
      
              onFocusChanged: {
                  console.log("clickableRect : onFocusChanged");
              }
              onActiveFocusChanged: {
                  console.log("clickableRect : onActiveFocusChanged");
              }
          }
      
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  //myFocusScope.focus = false;
                  clickableRect.focus = false;
                  myMenu.popup();
              }
              onFocusChanged: {
                  console.log("MouseArea : onFocusChanged");
              }
              onActiveFocusChanged: {
                  console.log("MouseArea : onActiveFocusChanged");
              }
              onEntered: {
                  console.log("MouseArea : onEntered");
      
              }
              onExited: {
                  console.log("MouseArea : onEntered");
              }
      
          }
      
      
          onFocusChanged: {
              console.log("root Rectangle : onFocusChanged");
          }
          onActiveFocusChanged: {
              console.log("root Rectangle : onActiveFocussChanged");
          }
      }
      

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            qt_sur qt_sur
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes