Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to detect Menu closed or dismissal?

$
0
0
Hi, I need to show certain visual changes on the UI only during the time when the Menu object is opened and user is about to select something. But the issue occurs when the user just dismisses the Menu and doesn’t select anything – I can’t seem to get any signals back. Here is the code from a simple test app: import QtQuick 2.0 import QtQuick.Controls 1.0  // needed for Label, Button   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: "Menu Item 1"                 checkable: true                 exclusiveGroup: myGroup             }             MenuItem {                 text: "Menu Item 2"                 checkable: true                 exclusiveGroup: myGroup             }         } // 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");         }     }         onFocusChanged: {         console.log("root Rectangle : onFocusChanged");     }     onActiveFocusChanged: {         console.log("root Rectangle : onActiveFocusChanged");     } } I also tried some stuff with FocusScope but couldn’t make it to work. Any help will be appreciated. Thanks.

Viewing all articles
Browse latest Browse all 4972

Trending Articles