"pop all" function for input handlers

Currently in my game, each scene of mine has a special input handler that gets pushed on init, and then popped when transitioning to a different scene. In some cases, there are sub-menus within scenes where i push new input handlers onto the stack.
If i transition to a new scene from here, I gotta make sure to call the pop function enough times to get rid of 'em all, which works but is pretty messy and relies on me knowing how many i hope to clear out.
So, I think a "pop all" function that removes every inputHandler except for the default playdate one could be a nice addition, just to keep it all tidied into one command and save me the baking or guesswork on my end.

1 Like

For anyone who sees this: the playdate.inputHandlers table is simply a table of all the input handlers (plus the push and pop functions) so it's relatively easy to check the number of handlers on the stack -- use #playdate.inputHandlers.

Though this should probably be in the docs somewhere...

4 Likes