@@ -47,8 +47,15 @@ UbuntuShape {
47 implicitHeight: MathUtils.clamp(listView.contentHeight, __ajustedMinimumHeight, __maximumHeight)
47 implicitHeight: MathUtils.clamp(listView.contentHeight, __ajustedMinimumHeight, __maximumHeight)
49 focus: true
49 focus: true
50 Keys.onUpPressed: d.selectPrevious(d.currentIndex)
51 Keys.onUpPressed: d.selectPrevious(d.currentIndex)
51 Keys.onDownPressed: d.selectNext(d.currentIndex)
52 Keys.onDownPressed: d.selectNext(d.currentIndex)
53+ Keys.onRightPressed: {
54+ // Don't let right keypresses fall through if the current item has a visible popup.
55+ if (!d.currentItem || !d.currentItem.popup || !d.currentItem.popup.visible) {
56+ event.accepted = false;
53 onVisibleChanged: {
60 onVisibleChanged: {
54 if (!visible) {
61 if (!visible) {
@@ -133,12 +140,6 @@ UbuntuShape {
138− objectName: "menuContext"
142 ColumnLayout {
143 ColumnLayout {
143 id: container
144 id: container
144 objectName: "container"
145 objectName: "container"
@@ -238,11 +239,26 @@ UbuntuShape {
244+ objectName: "menuContext"
246+ if (!root.visible) return false;
247+ if (d.currentItem && d.currentItem.popup && d.currentItem.popup.visible) {
241 delegate: Loader {
254 delegate: Loader {
242 id: loader
255 id: loader
257+ property int __ownIndex: index
245 enabled: model.isSeparator ? false : model.sensitive
260 enabled: model.isSeparator ? false : model.sensitive
261+ Keys.forwardTo: [ item ]
247 sourceComponent: {
263 sourceComponent: {
248 if (model.isSeparator) {
264 if (model.isSeparator) {
@@ -250,9 +266,8 @@ UbuntuShape {
251 return menuItemComponent;
267 return menuItemComponent;
253− property int __ownIndex: index
255− Keys.forwardTo: [ item ]
270+ property Item popup: null
257 Component {
272 Component {
258 id: menuItemComponent
273 id: menuItemComponent
@@ -260,9 +275,9 @@ UbuntuShape {
260 id: menuItem
275 id: menuItem
261 menuData: model
276 menuData: model
263− property Item popup: null
265 action.onTriggered: {
278 action.onTriggered: {
279+ d.currentItem = loader;
266 if (hasSubmenu) {
281 if (hasSubmenu) {
267 if (!popup) {
282 if (!popup) {
268 var model = root.unityMenuModel.submenu(__ownIndex);
283 var model = root.unityMenuModel.submenu(__ownIndex);
@@ -288,8 +303,8 @@ UbuntuShape {
288 Connections {
303 Connections {
289 target: d
304 target: d
290 onCurrentIndexChanged: {
305 onCurrentIndexChanged: {
291− if (menuItem.popup && d.currentIndex != __ownIndex) {
306+ if (popup && d.currentIndex != __ownIndex) {
292− menuItem.popup.visible = false;
307+ popup.visible = false;
@@ -302,7 +317,6 @@ UbuntuShape {
306 } // ListView
320 } // ListView
308 // FIXME use ListView.footer - tried but was flaky with positionViewAtIndex.
322 // FIXME use ListView.footer - tried but was flaky with positionViewAtIndex.
@@ -358,8 +372,10 @@ UbuntuShape {
358 value: submenuLoader.unityMenuModel
372 value: submenuLoader.unityMenuModel
361− onLoaded: item.select(0)
362 Keys.onLeftPressed: dismiss()
375 Keys.onLeftPressed: dismiss()
377+ Component.onCompleted: item.select(0);
378+ onVisibleChanged: if (visible) { item.select(0); }