- Edited
I'm having some trouble figuring out how to integrate custom menus with my game. I have a few menus that I'm autoloading as singletons and which I 'activate' by changing their visible flag. When their active, I want them to have first priority when it comes to handling input events. Eg, when I press left when my menu is open, I don't want my player character to move left as well.
This makes the Input class a problem, since it seems to report of the general state of keys rather than giving priority to a particular component. So I've switched to using unhandled_input() to detect keyboard and controller button events and listening to the on_root_gui_input() for mouse and touch events. While this works for now my code is slowly turning into spaghetti with so many different ways to look for input and not being quite sure which component gets an event first.
Is there a simpler way to create a menu? Like a modal dialog where as long as it's open it gets all the events and when it closes the game component starts getting them again?