Hi,
How can I remove 2 overlapping widgets one by one with escape?
Thanks in advance!
Hi,
How can I remove 2 overlapping widgets one by one with escape?
Thanks in advance!
How are you setting / keeping track of their Z order?
When I click escape the request widget is removed first, when I click again the pause menu is removed and the game continues.
for example like this one:
How are you setting / keeping track of their Z order?
I guess the answer is that you are not doing it.
Completely untested* but should work in a simple setup like this and without tracking Z order, even if you have multiple layers. Seems worth trying.
*tested below
that’s exactly what i did, didn’t work. The first widget is already open. You always have to click once on the background for the “on key down” to work.
You sure? Give it focus. Unless we’re talking about something different.
If I
And then:
Hitting Play and then Space (not touching the mouse) triggers it OK.
Also, since we’re in the menus, you can set the Input mode to UI only but this works with Game and UI, too.
There are 2 widgets open which are overlaid.
Nah. Can we address one thing at a time and agree that clicking a widget first is not necessary to give it focus, as in the demonstrated example? Or disagree? Also fine.
One thing that immediately jumps out here is when you give the widget focus. Think about it, you do it during Construct - this means the widget is yet to be in the viewport and is not ready to receive focus. That’s why you must click.
Focus after adding it to the viewport. If you must do it inside the widget itself, you could probably delay it but that’s somewhat sketchy.
Gave it a go and this theory seems to work quite well in practice:
Feed the consecutive widgets a reference of the one that created it and you can remove them in reverse order using keyboard:
Now that I’m thinking about I think I’ve used something similar before for making draggable stacking windows whose Z ordering was dynamic. A wee bit more tricky as you need to find the one with the highest Z first.
This looks very good, just how I want it!
Did not test with the actual native button, though - because I really dislike them so very much If you’re using them and they get focused, they will steal it from the rest of the widget.
You really are an expert!