Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | bloqm |
I need an UI element that lists selectable items, a.k.a. the basic videogame menu.
PopupMenu lets you select an item with a single click, and as you hover its items get highlighted – this is exactly what I need.
The problem is that popups can’t be really nested and doing so breaks the layout.
ItemList plays nicely with the layout, but by default it seems to work more like a filesystem folder, with doubleclick to confirm, mouse hover revealing tooltips but not hightlighting… etc.
I haven’t found another built-in node that does what I want. So:
- Is there a way to make a PopupMenu fit inside a layout?
- If that’s not possible (or a bad idea), how can I modify ItemList to work as I want? (highlight items on hover, single-click to confirm)
I should note that I need it to work with both keyboard and mouse. PopupMenu does this by default, but I had trouble changing the input of ItemList in a consistent way.
Thanks!
What you mean “The problem is that popups can’t be really nested and doing so breaks the layout.”? Nested popups can be implemented as submenus. And you can set the position by setting anchors and margins in code:
Menu.anchor_left = ~
Menu.margin_top = ~
dewcked | 2021-11-25 09:12
Thanks. Nested was a poor word choice; I mean that Popups cannot be integrated inside other containers such as VBox, like in my example below (those are ItemLists).
Unless I’m mistaken, a popup always “floats” above other elements disregarding its parent, and containers don’t account for its size when spacing elements.
bloqm | 2021-11-25 16:03