Fix: CardWidget double-click causes immediate select→deselect cycle
Godot 4 fires two separate pressed=true InputEventMouseButton events for a fast click: a normal press and a double_click press, both in the same frame. The previous _gui_input emitted card_pressed for both, so the first emission selected the card and the second (double_click) immediately deselected it. Fix: - Skip card_pressed emission when event.double_click is true - Consume RELEASE as well as PRESS so neither can leak to the 3D board's _unhandled_input handler (belt-and-suspenders over the _press_was_on_board guard that already exists in game_screen.gd) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -190,8 +190,14 @@ func get_definition_id() -> String:
|
||||
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
card_pressed.emit(_definition_id)
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
var mb := event as InputEventMouseButton
|
||||
# Consume both press and release so neither leaks to the 3D board's
|
||||
# _unhandled_input. Only emit card_pressed on a plain press — not on
|
||||
# double-click (which Godot fires as a *second* pressed=true event in
|
||||
# the same frame, causing an immediate select → deselect cycle).
|
||||
if mb.pressed and not mb.double_click:
|
||||
card_pressed.emit(_definition_id)
|
||||
accept_event()
|
||||
elif event is InputEventScreenTouch and event.pressed:
|
||||
card_pressed.emit(_definition_id)
|
||||
|
||||
Reference in New Issue
Block a user