How to stop keypress events from propegating when a popup window is open?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kitfox

I’ve created a menu with a grid of buttons in it that allows the user to choose from one of a set of items. It is contained within a popup menu - the idea is that whenever the user wants to select an item, they open this menu and then click on the item the want.

The trouble is coming from keyboard controls. Whenever the menu is open and one of the left most buttons is selected and the user presses ‘ui_left’, the key event is picked up by my game layer instead of my grid of buttons (which is causing the user to look left when they press left while on the left side of the menu, and similar for the other menu sides).

How do I get my popup window to absorb all of the keyboard events while it is open and not pass them along to my game layer?

:bust_in_silhouette: Reply From: exuin

get_tree().set_input_as_handled() assuming player movement is in _unhandled_input()