Fix touch: use cumulative drag distance to distinguish taps from swipes
4px per-event threshold was too sensitive — normal finger tremor during a tap could exceed it, causing _touch_drag_active to suppress the click. Now accumulates total drag distance since touch-down; requires 12px total movement before classifying the touch as a camera orbit. 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:
@@ -123,8 +123,9 @@ var _pinch_dist : float = 0.0
|
|||||||
# True from the moment a second finger lands until ALL fingers lift.
|
# True from the moment a second finger lands until ALL fingers lift.
|
||||||
# Prevents single-finger orbit from triggering during a pinch gesture even
|
# Prevents single-finger orbit from triggering during a pinch gesture even
|
||||||
# if a ScreenDrag for finger-0 arrives before finger-1's ScreenTouch is processed.
|
# if a ScreenDrag for finger-0 arrives before finger-1's ScreenTouch is processed.
|
||||||
var _was_multi_touch : bool = false
|
var _was_multi_touch : bool = false
|
||||||
var _touch_drag_active : bool = false # set when finger moves > threshold; suppresses tap-click
|
var _touch_drag_active : bool = false # set when cumulative finger movement > threshold; suppresses tap-click
|
||||||
|
var _touch_drag_total : float = 0.0 # cumulative drag distance since last touch-down
|
||||||
|
|
||||||
# ── Selection state ───────────────────────────────────────────────────────────
|
# ── Selection state ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -817,6 +818,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
_handle_board_click(mb.position)
|
_handle_board_click(mb.position)
|
||||||
_drag_active = false
|
_drag_active = false
|
||||||
_touch_drag_active = false
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
_press_was_on_board = false
|
_press_was_on_board = false
|
||||||
|
|
||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
@@ -854,6 +856,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if _touch_points.size() == 1:
|
if _touch_points.size() == 1:
|
||||||
# Single-touch start: arm tap + hold (touch right-click) behavior.
|
# Single-touch start: arm tap + hold (touch right-click) behavior.
|
||||||
_touch_drag_active = false
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
_press_was_on_board = true
|
_press_was_on_board = true
|
||||||
_last_mouse = st.position
|
_last_mouse = st.position
|
||||||
var touch_coord := _mouse_to_tile_coord(st.position)
|
var touch_coord := _mouse_to_tile_coord(st.position)
|
||||||
@@ -878,6 +881,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if _touch_points.is_empty():
|
if _touch_points.is_empty():
|
||||||
_was_multi_touch = false
|
_was_multi_touch = false
|
||||||
_touch_drag_active = false
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
_press_was_on_board = false
|
_press_was_on_board = false
|
||||||
_held_coord = Vector2i(-1, -1)
|
_held_coord = Vector2i(-1, -1)
|
||||||
_hold_timer.stop()
|
_hold_timer.stop()
|
||||||
@@ -886,7 +890,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
var sd := event as InputEventScreenDrag
|
var sd := event as InputEventScreenDrag
|
||||||
_touch_points[sd.index] = sd.position
|
_touch_points[sd.index] = sd.position
|
||||||
if _touch_points.size() == 1 and not _was_multi_touch:
|
if _touch_points.size() == 1 and not _was_multi_touch:
|
||||||
if sd.relative.length() > 4.0:
|
_touch_drag_total += sd.relative.length()
|
||||||
|
if _touch_drag_total > 12.0:
|
||||||
_touch_drag_active = true
|
_touch_drag_active = true
|
||||||
_hold_timer.stop()
|
_hold_timer.stop()
|
||||||
if _touch_drag_active:
|
if _touch_drag_active:
|
||||||
|
|||||||
Reference in New Issue
Block a user