Mouse State Tracking and Enter/Exit Events #140
Labels
No Label
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: john/McRogueFace#140
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Track mouse position and hovered element in C++, fire Python callbacks only on state transitions.
Context
Python currently has no awareness of mouse position or hover state. Games need hover highlighting, tooltips, and similar UX patterns. Following the "C++ every frame, Python every tick" philosophy, C++ tracks state and only calls Python when state changes.
Definition of Done
C++ Side (every frame)
on_exiton previous element (if changed and callback set)on_enteron new element (if changed and callback set)Python Side (queryable)
mcrfpy.mouse_posproperty →(x, y)tuple, read-onlydrawable.hoveredproperty →bool, read-onlyCallbacks
drawable.on_enter- called when mouse enters bounds, no argumentsdrawable.on_exit- called when mouse leaves bounds, no argumentsTechnical Notes
State Machine
Hit Testing Order
Iterate UI elements in reverse render order (last rendered = topmost = first to test).
Stop at first hit. Only the topmost element receives enter/exit events.
Nested Elements
A Frame containing a Caption: if mouse is over the Caption, only the Caption gets
on_enter. The Frame does NOT geton_enterunless the mouse is over the Frame but not over any child.This matches typical GUI behavior. If bubble-up is needed later, it's a separate enhancement.
Performance
When
on_enterandon_exitare both None (common case), the Python call overhead is zero. C++ still tracks state for thehoveredproperty query.Dependencies
Related Issues