0 votes

Hi!
I have a RTS-type mechanic in my game with contextual popups appearing at various points and it's kinda important that the player is able to select things from the popup rather quickly. Since speed is a factor, i want to also add the ability to select items in a popup with the keyboard. Is it possible to assign item IDs belonging to a popup to keys and trigger them on keypress?

in Engine by (393 points)

1 Answer

0 votes

I'm using this event handler in game scene, it checks if popup is_visible() and call things for various key presses:

func _input(event):
if event is InputEventKey and event.pressed:
    if menu_popup.is_visible():
        match event.scancode:
            KEY_Q, KEY_ESCAPE:
                menu_popup.hide()
            KEY_1:
                run_first_command()                        
by (126 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.