diff options
author | Kari Hautamäki <kari.hautamaki@qt.io> | 2017-02-09 16:43:22 +0200 |
---|---|---|
committer | Titta Heikkala <titta.heikkala@qt.io> | 2017-02-10 05:41:22 +0000 |
commit | 3bfd8426a8e5bb84516101b14398a0bc34f7ef71 (patch) | |
tree | 5703f2d43d7088cefc06bf60523980419fbf6113 /tradeshow/iot-sensortag | |
parent | a3447ec9896902354d89284cafba1e1dbac17774 (diff) |
iot-sensortag: Hide menus by clicking outside
Add a fullscreen MouseArea that is used to close a menu
when clicked outside of the menu
Change-Id: I1479519f6f14be56c12445b92b0c05d519dc7f01
Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag')
-rw-r--r-- | tradeshow/iot-sensortag/resources/base/TopToolbar.qml | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml index af6aba2..85dcb69 100644 --- a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml +++ b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml @@ -58,21 +58,24 @@ Item { width: implicitWidth CloudSettings { - id: cloudSettins + id: cloudSettings + x: cloudItem.x - y: parent.height + y: topToolbar.height visible: false } SensorSettings { id: sensorList + x: sensorItem.x - y: parent.height + y: topToolbar.height visible: false } Item { id: cloudItem + height: topToolbar.height anchors.top: parent.top anchors.left: parent.left @@ -102,7 +105,7 @@ Item { MouseArea { anchors.fill: parent - onClicked: cloudSettins.visible = !cloudSettins.visible + onClicked: clickBait.activate(cloudSettings) } } @@ -143,7 +146,7 @@ Item { MouseArea { anchors.fill: parent - onClicked: sensorList.visible = !sensorList.visible + onClicked: clickBait.activate(sensorList) } } @@ -192,4 +195,30 @@ Item { anchors.bottomMargin: -18 source: pathPrefix + "Toolbar/topbar_all.png" } + + MouseArea { + id: clickBait + + property var menu + + function activate(menuItem) { + menu = menuItem; + menuItem.visible = true; + menuItem.parent = clickBait; + } + + function deactivate() { + menu.parent = topToolbar; + menu.visible = false; + menu = null; + } + + width: main.width + height: main.height + enabled: menu ? true : false + onClicked: { + if (!childAt(mouseX, mouseY)) + deactivate(); + } + } } |