From 9f06af967641d6921b35397be6e4b92dcfea864c Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Tue, 10 Nov 2026 19:38:15 -0600 Subject: [PATCH] Fix: resize corner caught clicks far outside cards; left-drag selects in Play too CardGrip._has_point only checked 'right of and below' the corner, and Godot asks controls about points outside their box, so everything to the bottom-right of every card acted as its resize handle. It's now bounded to the corner square inside the card. A left-drag on empty space now draws a selection box in Play as well as Build, and selected cards move together in both; panning is middle-drag or Space+drag. Co-Authored-By: Claude Opus 5.5 --- help/topics.txt | 4 ++-- tests/test_card_size.gd | 32 ++++++++++++++++++++++++++++++++ ui/board_view.gd | 7 ++++--- ui/card_grip.gd | 4 +++- ui/main_selection.gd | 2 +- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/help/topics.txt b/help/topics.txt index 6124a09..1ef4ed4 100644 --- a/help/topics.txt +++ b/help/topics.txt @@ -161,7 +161,7 @@ Right-click almost anything for what you can do with it. On a phone or tablet, p The [b]☰[/b] button in the top bar has the same things as right-clicking empty space. # Selecting, moving and resizing -- In Build, drag a box on empty space to select cards and groups. Hold [b]Ctrl[/b] or [b]Shift[/b] to add to the selection. +- Drag a box on empty space to select cards and groups. Hold [b]Ctrl[/b] or [b]Shift[/b] to add to the selection. - Drag any selected card or group and everything selected moves together. - Drag the small lines in a card's bottom-right corner to make it wider or taller; a taller card's results scroll inside it. Double-click the corner to go back to its own size. - Cards can go anywhere: there's no edge to the spread. @@ -240,7 +240,7 @@ Click any item in the report to jump to that card. A spread that can loop foreve # Finding your way - [b]Search[/b] (the magnifier, or [b]Ctrl+F[/b]) finds cards by name, result, question, value or group, opens closed groups and flashes the card. -- Drag with the middle mouse button, or hold [b]Space[/b] and drag, to move around (in Play a plain drag works too). The mouse wheel scrolls up and down, [b]Shift+wheel[/b] scrolls sideways and [b]Ctrl+wheel[/b] zooms. +- Drag with the middle mouse button, or hold [b]Space[/b] and drag, to move around. The mouse wheel scrolls up and down, [b]Shift+wheel[/b] scrolls sideways and [b]Ctrl+wheel[/b] zooms. - The zoom control at the top right shows the zoom. − and + step it, and the percentage opens [b]Fit spread[/b], [b]Zoom to 100%[/b] and the minimap. - The [b]minimap[/b] (press [b]M[/b]) shows the whole spread in the corner. Click or drag on it to move there. diff --git a/tests/test_card_size.gd b/tests/test_card_size.gd index c1e27a4..189a19e 100644 --- a/tests/test_card_size.gd +++ b/tests/test_card_size.gd @@ -17,6 +17,7 @@ func _init() -> void: await _frames(5) await _test_resize() await _test_compact() + await _test_play_drag_selects() print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures]) quit(1 if _failures else 0) @@ -27,6 +28,7 @@ func _test_resize() -> void: var grip := card.grip _check(grip != null and grip.get_index() == card.get_child_count() - 2 and card.shield.get_index() == card.get_child_count() - 1, "the grip, then the shield, are the card's last children") _check(grip._has_point(grip.size - Vector2(4, 4)) and not grip._has_point(Vector2(4, 4)), "only the corner takes the mouse") + _check(not grip._has_point(grip.size + Vector2(5, 5)) and not grip._has_point(grip.size + Vector2(300, -4)) and not grip._has_point(Vector2(grip.size.x - 4, grip.size.y + 200)), "nothing outside the card is the resize corner") var auto_w := card.size.x card.set_user_size(380.0, 120.0) await _frames() @@ -64,6 +66,36 @@ func _test_compact() -> void: _check(not main.board.compact and not card.shield.visible, "zoomed in, the shield is gone") +## In Play, a left-drag on empty space draws a selection box; it doesn't pan. +func _test_play_drag_selects() -> void: + main.set_mode(Main.Mode.PLAY) + main.clear_selection() + main.board.set_zoom(0.5) + await _frames() + var card := main.card_for("road") + var r := card.get_global_rect() + var from := r.position - Vector2(20, 20) - main.board.global_position + var to := r.position + Vector2(40, 40) - main.board.global_position + var before := main.board.world.position + var press := InputEventMouseButton.new() + press.button_index = MOUSE_BUTTON_LEFT + press.pressed = true + press.position = from + main.board._gui_input(press) + var move := InputEventMouseMotion.new() + move.position = to + move.relative = to - from + main.board._gui_input(move) + var up := press.duplicate() as InputEventMouseButton + up.pressed = false + up.position = to + main.board._gui_input(up) + await _frames() + _check(main.board.world.position == before, "a left-drag doesn't pan") + _check(main.selection.has("road"), "it selects what the box touches") + main.clear_selection() + + func _frames(n: int = 2) -> void: for i in n: await process_frame diff --git a/ui/board_view.gd b/ui/board_view.gd index b03ce73..5bc7013 100644 --- a/ui/board_view.gd +++ b/ui/board_view.gd @@ -317,16 +317,17 @@ func _gui_input(ev: InputEvent) -> void: if mb: match mb.button_index: MOUSE_BUTTON_LEFT, MOUSE_BUTTON_MIDDLE: - # Middle-drag or Space+drag pans anywhere; in Play a left-drag pans too. + # Middle-drag or Space+drag pans; a left-drag on empty space draws a + # selection box, in Play and Build alike. var pan_drag := mb.button_index == MOUSE_BUTTON_MIDDLE or Input.is_key_pressed(KEY_SPACE) - var build_left := mb.button_index == MOUSE_BUTTON_LEFT and main.mode == Main.Mode.BUILD and not pan_drag + var build_left := mb.button_index == MOUSE_BUTTON_LEFT and not pan_drag if mb.pressed: # Clicking the felt leaves a text field, so Ctrl+Z undoes on the board. var f := get_viewport().gui_get_focus_owner() if f is LineEdit or f is TextEdit: f.release_focus() if build_left: - var key := pipes.pipe_at(world_mouse(), 11.0) + var key := pipes.pipe_at(world_mouse(), 11.0) if main.mode == Main.Mode.BUILD else "" if key != "": # The pipe opens in the inspector (Main.open_pipe_options). main.open_pipe_options(key, mb.global_position) diff --git a/ui/card_grip.gd b/ui/card_grip.gd index e59e077..f9feb58 100644 --- a/ui/card_grip.gd +++ b/ui/card_grip.gd @@ -25,8 +25,10 @@ func _init(p_card: TableCard) -> void: tooltip_text = "Drag to resize the card. Double-click for its automatic size." +## Only the corner square, inside the card. (Godot asks about points outside a +## control's box too, so both edges of the square need checking.) func _has_point(p: Vector2) -> bool: - return p.x >= size.x - HIT and p.y >= size.y - HIT + return p.x >= size.x - HIT and p.y >= size.y - HIT and p.x <= size.x and p.y <= size.y func _draw() -> void: diff --git a/ui/main_selection.gd b/ui/main_selection.gd index e690a6a..fc33142 100644 --- a/ui/main_selection.gd +++ b/ui/main_selection.gd @@ -68,7 +68,7 @@ func covers_group(gid: String) -> bool: ## True when dragging this card should move the whole selection. func moves_together(tid: String) -> bool: - return m.mode == Main.Mode.BUILD and (m.selection.has(tid) or covers(tid)) \ + return (m.selection.has(tid) or covers(tid)) \ and m.selection.size() + groups.size() > 1