While trying to open a popupmenu from another popupmenu, I ran into a tiny problem. Both the menus close when I open the submenu. A temporary solution I'm using is closing the original menu on click and the submenu remains open then. I think they're both trying to grab the focus and close due to that. Does anyone know a reasonable way of creating hierarchical popupmenus in gnome shell extensions?
Asked
Active
Viewed 1,243 times
1 Answers
1
The menu system in the shell is a little bit convoluted with regard to the signals and opening and closing. You should definitely have a look a popupMenu.js if you haven't already.
If I recall from my own adventures, it's not possible to have submenus in submenus because of the way the signals propagate but you can subclass any of those classes and modify the signals, or you can fake your own submenus by adding manipulating the visibility
property:
Also have a look at PopupMenuSection class with it's comment:
deliberately ignore any attempt to open() or close(), but emit the corresponding signal so children can still pick it up

andy.holmes
- 3,383
- 17
- 28
-
Ok, I tried to replace the close function in my subclass and it keeps the menu open now. However I still have an issue with the code. How do I access or replicate the original close function? – varikas Oct 19 '17 at 15:54
-
You should be able to call the "prototype" which is sort of a Javascript "super"-thing. Try `PopupMenu.PopupSubMenu.prototype.close.call(this);` where PopupSubMenu is whichever class you've subclassed. On the other hand, you might want one of [these functions](https://github.com/GNOME/gnome-shell/blob/master/js/ui/popupMenu.js#L1134-L1167). I ended up using `this._getTopMenu().close()` and closing the whole thing down, because that worked for my use-case. – andy.holmes Oct 20 '17 at 01:42