@@ -40,27 +40,32 @@ UbuntuShape {
4040 readonly property real __maximumWidth: Screen.width * 0.7
4141 readonly property real __maximumHeight: Screen.height * 0.7
4242
43+ function show() {
44+ visible = true;
45+ focusScope.forceActiveFocus();
46+ }
47+
48+ function hide() {
49+ visible = false;
50+ d.currentItem = null;
51+ }
52+
4353 function select(index) {
4454 d.select(index)
4555 }
4656
4757 function reset() {
4858 d.currentItem = null;
59+ dismiss();
4960 }
5061
5162 function dismiss() {
52− d.dismissAll()
63+ d.dismissAll();
5364 }
5465
5566 implicitWidth: container.width
5667 implicitHeight: MathUtils.clamp(listView.contentHeight, __ajustedMinimumHeight, __maximumHeight)
5768
58− onVisibleChanged: {
59− if (!visible) {
60− d.currentItem = null;
61− }
62− }
63−
6469 MenuNavigator {
6570 id: d
6671 objectName: "d"
@@ -85,7 +90,7 @@ UbuntuShape {
8590 }
8691 }
8792
88− FocusScope {
93+ Item {
8994 id: focusScope
9095 anchors.fill: parent
9196 focus: visible
@@ -250,7 +255,7 @@ UbuntuShape {
250255 } else if (popup) {
251256 popup.visible = true;
252257 }
253− popup.dismiss.connect(function() {
258+ popup.retreat.connect(function() {
254259 popup.destroy();
255260 popup = null;
256261 menuItem.forceActiveFocus();
@@ -267,6 +272,12 @@ UbuntuShape {
267272 popup.visible = false;
268273 }
269274 }
275+ onDismissAll: {
276+ if (popup) {
277+ popup.destroy();
278+ popup = null;
279+ }
280+ }
270281 }
271282 }
272283 }
@@ -325,7 +336,7 @@ UbuntuShape {
325336 source: "MenuPopup.qml"
326337
327338 property var unityMenuModel: null
328− signal dismiss()
339+ signal retreat()
329340
330341 Binding {
331342 target: item
@@ -339,12 +350,7 @@ UbuntuShape {
339350 value: submenuLoader.objectName + "menu"
340351 }
341352
342− Connections {
343− target: d
344− onDismissAll: submenuLoader.dismiss()
345− }
346−
347− Keys.onLeftPressed: dismiss()
353+ Keys.onLeftPressed: retreat()
348354
349355 Component.onCompleted: item.select(0);
350356 onVisibleChanged: if (visible) { item.select(0); }