Fix items not responding to clicks #12

Merged
scruffydude merged 1 commit from fix/item-click-not-registering into main 2026-10-01 23:01:47 -04:00
Owner

Root cause: every ColorRect/Label visual is a Control node, and Control.mouse_filter defaults to STOP — which silently swallows mouse clicks before anything else sees them. The full-screen Floor rect alone was blocking clicks across the entire window. Set mouse_filter = 2 (ignore) on all purely-decorative visuals.

Also switched items from Area2D/_input_event (physics picking) to a plain Node2D with manual point-in-rect hit testing in _unhandled_input. Physics picking never fired in headless testing despite every relevant flag being correct; removing that dependency makes click detection simpler and verifiable from this sandbox rather than trusting an unverifiable mechanism.

Verified headlessly: _unhandled_input now reaches item nodes (previously swallowed by their own Visual ColorRect), hit-test math is correct for all three items, and the full #3/#4 regression suite still passes after the Area2D→Node2D change.

Not verifiable from this sandbox: end-to-end click-to-drag through the real mouse pipeline, since get_global_mouse_position() returns a fixed dummy value in headless mode regardless of synthetic input. Needs a real windowed test — next build should confirm.

Root cause: every ColorRect/Label visual is a Control node, and `Control.mouse_filter` defaults to STOP — which silently swallows mouse clicks before anything else sees them. The full-screen `Floor` rect alone was blocking clicks across the entire window. Set `mouse_filter = 2` (ignore) on all purely-decorative visuals. Also switched items from `Area2D`/`_input_event` (physics picking) to a plain `Node2D` with manual point-in-rect hit testing in `_unhandled_input`. Physics picking never fired in headless testing despite every relevant flag being correct; removing that dependency makes click detection simpler and verifiable from this sandbox rather than trusting an unverifiable mechanism. Verified headlessly: `_unhandled_input` now reaches item nodes (previously swallowed by their own Visual ColorRect), hit-test math is correct for all three items, and the full #3/#4 regression suite still passes after the Area2D→Node2D change. **Not verifiable from this sandbox:** end-to-end click-to-drag through the real mouse pipeline, since `get_global_mouse_position()` returns a fixed dummy value in headless mode regardless of synthetic input. Needs a real windowed test — next build should confirm.
Root cause: every ColorRect/Label visual (including the full-screen
Floor rect) is a Control node, and Control.mouse_filter defaults to
STOP. That silently swallowed every mouse click in the game before it
could reach anything else - the Floor alone blocked the entire
window. Set mouse_filter = 2 (ignore) on all purely-decorative
visuals so clicks pass through them.

While fixing this, also moved items off Area2D/_input_event (physics
picking) onto a plain Node2D with manual point-in-rect hit testing in
_unhandled_input. Physics picking never fired in headless testing
despite input_pickable, collision_layer, and
Viewport.physics_object_picking all being correctly set - removing
that dependency makes the click detection both simpler and something
I can actually verify from this sandbox, rather than trusting a
mechanism I couldn't confirm was working.

Verified headlessly:
- _unhandled_input now fires on item nodes for a click at their exact
  position (previously would have been swallowed by the item's own
  Visual ColorRect before the mouse_filter fix).
- _contains_point() hit-test math is correct for all three items'
  click boxes (center inside, just past each half-extent outside).
- Full snap-to-stand and win-condition regression suite (#3, #4)
  still passes after the Area2D -> Node2D change.

Could not verify end-to-end click-to-drag through Godot's real mouse
pipeline from this sandbox: get_global_mouse_position() returns a
fixed dummy-driver value in headless mode regardless of the synthetic
event's position, so that specific path needs a real windowed test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Nimby referenced this pull request from a commit 2026-10-01 23:17:13 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
scruffydude/project-awry!12
No description provided.