Hello everyone!
I’m pretty new to BP coding and I’m trying to setup a “Pause menù” for the project.
No particular issue at all, but one.
Pressing “P” create a new widget → Re-Pressing “P” close the first widget → clicking on “options” open a new widget along with the first one on the background but in this stage of testing I saw that when I press “P” again when the “Options” widget is opened the action doesn’t close widgets in order but only close the main pause menù in the background leaving the “options” one on the screen causing something I can’t resolve.
I tried using “Listen for Input Action” and “Set priority Action” but even after reading documentation and a tutorial I still can’t figure out to resolve the problem, setting priority just disabled the functionality to press P to going back into the menu and nothing else.
I could resolve all this just disabling the Action “P” to be executed when in pause, so the player can only use “back” button in the widget for going back. But honestly this fix is a lazy one and if I was a player I will be pretty mad to not be able to use “Esc”(P) to go back in the menus.
Can someone be so patient to help a dumb one like me? I know the fix is probably easy but still I can’t figure it out. And that’s funny because I made an Event System based on Days and Time with no help at all but I can’t fix a stuff like this…
Here some screens that can may be helpfull
(InputPauseMenu is the action binded for P & Esc)
1st screen is the Main Pause menù Widget’s graph
2nd screen is the Sub-menù Option Widget’s graph
If you are going to “re-press” the same button, I would suggest using a FLIP FLOP node and putting in either ADD TO VIEWPORT or REMOVE FROM PARENT, depending on which widget you want to have exposed. I would drop the whole Listen for Input node.
I think the solution you are looking for is to check if the widget is currently in focus. Use this as a bool to check if it is the topmost/in focus window to allow you to remove from parent.
So, first of all sorry for let you all wait for a response.
I tried this solution but it worked basically like a “switch” leaving only one widget on the screen so not closing them in sequence like I wanted. Maybe I used it wrong idk but it didn’t work to well as solution for the project. Anyway big thanks for your time, very appreciated.
This one. This one was kinda a solution but still didn’t work for some reason and I managed to make it work with some brain-dead adjusment wich only my mind can do to avoid doing stuff properly.
I’m leaving the solution here for people that need the same “widget closing system” as mine but also for make a last question (is not a real problem I think).
I managed to make it work with “Listen for Input Priority” and this time, idk why, it worked.
ThirdPersonCharacter BP(yeah the Sequence node is useless, I was trying other solution and forgot to delete it).
The code will check if the main menù has the focus and allow to remove it from parent only if the “AND node” is satisfied.
For some reason without all the stuff fired by “Event Construct” I was able to close the “Options” windows but the main menù (with the AND condition setted) didn’t work making the Input “P” not working anymore (after option closed) leaving the main menù on the viewport. With that stuff, now work and widgets closes in sequence exactly as I wanted.
The “problem” I was talking before is a ‘warning’ in the debug log:
I think this happen because the Pause menù is locked by the AND condition so when I press P everything work but the code check the “Is Valid” node doing nothing because the Widget already exist. Now my question is: Should I manage to fix this kind of loop/re-check condition or is only a debug stuff that I can ignore? And most important, should I ignore it or not? But maybe I know yet the answer I’m finding.
Some idea for fix this stuff? I will try some stuff I have in mind when back to home (im currently working) but if some of you have yet a solution is really appreciated