add better checks for mouse buttons
This commit is contained in:
@@ -12,10 +12,15 @@ func _ready() -> void:
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if (event as InputEventMouseButton).pressed:
|
||||
_set_cursor(cursor_click)
|
||||
else:
|
||||
_set_cursor(cursor_normal)
|
||||
var button_event := event as InputEventMouseButton
|
||||
if (
|
||||
button_event.button_index == MOUSE_BUTTON_LEFT
|
||||
or button_event.button_index == MOUSE_BUTTON_RIGHT
|
||||
):
|
||||
if button_event.pressed:
|
||||
_set_cursor(cursor_click)
|
||||
else:
|
||||
_set_cursor(cursor_normal)
|
||||
|
||||
|
||||
func _set_cursor(image: Resource) -> void:
|
||||
|
||||
@@ -47,10 +47,11 @@ func _process(_delta: float) -> void:
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var button_event := event as InputEventMouseButton
|
||||
mouse_pressed = button_event.pressed
|
||||
if mouse_pressed:
|
||||
selection_rect.position = button_event.position
|
||||
selection_rect.size = Vector2.ZERO
|
||||
if button_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
mouse_pressed = button_event.pressed
|
||||
if button_event.pressed:
|
||||
selection_rect.position = button_event.position
|
||||
selection_rect.size = Vector2.ZERO
|
||||
|
||||
if event is InputEventMouseMotion and mouse_pressed:
|
||||
var motion_event := event as InputEventMouseMotion
|
||||
|
||||
@@ -27,7 +27,10 @@ func _physics_process(_delta: float) -> void:
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and selected:
|
||||
var button_event := event as InputEventMouseButton
|
||||
if button_event.pressed:
|
||||
if (
|
||||
button_event.button_index == MOUSE_BUTTON_LEFT
|
||||
and button_event.pressed
|
||||
):
|
||||
_set_target_click(button_event.position)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user