fix #162 catch input events when they have been processed by the board

This commit is contained in:
betalars 2025-05-16 13:19:22 +02:00
parent 96e799f73e
commit 90a836fa23
1 changed files with 12 additions and 5 deletions

View File

@ -329,17 +329,19 @@ func insert_area(parent: Control, node: Area2D):
# Takes the inputs for control inputs
func _input(event):
if event.is_action_pressed("ui_cancel"):
State.leave_stage(self)
# Return, if the input is a mouse event (mouse events are handled separately)
if not has_stage or not is_instance_valid(currently_active_node): return
if event.is_action_pressed("ui_cancel"):
State.leave_stage(self)
get_viewport().set_input_as_handled()
if event is InputEventMouse:
# makes sure to pass release events so notes do not get attached to the mouse while the cursor leaves the area.
if event is InputEventMouseButton and current_context == DRAG:
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
handle_mouse_button(event)
get_viewport().set_input_as_handled()
else:
return
@ -349,12 +351,14 @@ func _input(event):
current_sticky_note_id -= 1
else:
current_dropzone_id -= 1
get_viewport().set_input_as_handled()
elif event.is_action_pressed("ui_down"): # down to select an element beneath
if focus_stickies:
current_sticky_note_id += 1
else:
current_dropzone_id += 1
get_viewport().set_input_as_handled()
elif event.is_action_pressed("ui_right"): # left to switch context to the left
if not focus_stickies:
@ -362,6 +366,7 @@ func _input(event):
focus_stickies = true
elif current_context == ASSIGN:
current_context = NAVIGATE
get_viewport().set_input_as_handled()
elif event.is_action_pressed("ui_left"): # right to switch context to the right
if focus_stickies:
@ -369,6 +374,7 @@ func _input(event):
focus_stickies = false
elif current_context == ASSIGN:
current_context = NAVIGATE
get_viewport().set_input_as_handled()
elif event.is_action_pressed("ui_accept"): # select the selected note it
if dropzone.get_child(current_dropzone_id) is Card:
@ -404,6 +410,7 @@ func _input(event):
current_dropzone_id += 1
currently_active_node.is_dragable = false
currently_active_node.z_index = 1
get_viewport().set_input_as_handled()
# move the note it so it floats next to the card where it should be attached
func _select_card_for_assigning(sticky_note: Area2D, card: Area2D):