fix: cards now properly talk to the right handler.
This commit is contained in:
parent
9990a80845
commit
03f427b76a
|
|
@ -278,4 +278,4 @@ func handle_drop(draggable: StickyNote) -> int:
|
|||
|
||||
## Cards always drop back to board dropzone
|
||||
func find_drop_target() -> Node:
|
||||
return _get_board()
|
||||
return _get_button_handler()
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ func _get_hover_handler() -> Node:
|
|||
|
||||
|
||||
## Walks up the scene tree to find the CardBoard
|
||||
func _get_board() -> CardBoard:
|
||||
func _get_button_handler() -> Node:
|
||||
var node := get_parent()
|
||||
while node:
|
||||
if node.has_method("handle_mouse_button"):
|
||||
return node as CardBoard
|
||||
return node
|
||||
node = node.get_parent()
|
||||
return null
|
||||
|
||||
|
|
@ -94,13 +94,15 @@ func _input(event: InputEvent) -> void:
|
|||
if is_dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_released():
|
||||
is_dragged = false
|
||||
# Trigger the drop logic
|
||||
_get_board().handle_mouse_button(event, self)
|
||||
var handler := _get_button_handler()
|
||||
if handler: handler.handle_mouse_button(event, self)
|
||||
|
||||
|
||||
## Handles input events on this Area2D (used to start drag)
|
||||
func _on_input_event(_viewport, event, _shape_idx):
|
||||
if highlighted and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
_get_board().handle_mouse_button(event, self)
|
||||
var handler := _get_button_handler()
|
||||
if handler: handler.handle_mouse_button(event, self)
|
||||
|
||||
|
||||
## Starts a drag operation
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ var random_player: AnimationPlayer
|
|||
|
||||
var card_anim_skipped:bool = false
|
||||
|
||||
func _input(event : InputEvent):
|
||||
func _input(event : InputEvent) -> void:
|
||||
if _input_locked: return
|
||||
|
||||
# Navigation
|
||||
|
|
|
|||
|
|
@ -113,9 +113,11 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
|
||||
if event.is_action_pressed("ui_pause"):
|
||||
state = AppState.PAUSE
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
if not Engine.is_editor_hint():
|
||||
if event.is_action_pressed("toggle_fullscreen"):
|
||||
get_viewport().set_input_as_handled()
|
||||
# I have no idea why I wrote thit as convoluted,
|
||||
# but it works(TM) so I am not gonna change it :D
|
||||
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
|
|
|
|||
|
|
@ -22,3 +22,7 @@ func _on_help_pressed():
|
|||
func appear():
|
||||
show()
|
||||
%ResumeButton.grab_focus.call_deferred()
|
||||
|
||||
func _unhandled_input(_event: InputEvent) -> void:
|
||||
if not visible: return
|
||||
get_viewport().set_input_as_handled()
|
||||
|
|
|
|||
Loading…
Reference in New Issue