0 votes

How can I find out if a button was pressed with the right or left mouse button?

This didn't work:

func _on_Button_pressed():
    if Input.is_key_pressed(BUTTON_LEFT):
        # left button clicked
    elif Input.is_key_pressed(BUTTON_RIGHT):
         # right button clicked
in Engine by (41 points)

1 Answer

+3 votes
Best answer

Connect the gui_input-signal:

func _on_Button_gui_input(event):
    if event is InputEventMouseButton and event.pressed:
        match event.button_index:
                # left button clicked
                # right button clicked
by (10,327 points)
selected by

Thank you very much!

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.