DimOkGamer

Godot Engine Button Left & Right clicks

Feb 26th, 2022 (edited)
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Extends BaseButton functionality to distinguish
  2. # right and left mouse clicks.
  3. # So you can use this script with any type of button.
  4.  
  5. extends BaseButton
  6.  
  7. signal left_click
  8. signal right_click
  9.  
  10. func _gui_input(event):
  11.     if event is InputEventMouseButton and !event.pressed and get_rect().has_point(event.position):
  12.         match event.button_index:
  13.             BUTTON_LEFT:
  14.                 emit_signal("left_click")
  15.             BUTTON_RIGHT:
  16.                 emit_signal("right_click")
  17.  
Add Comment
Please, Sign In to add comment