[Demo] Widget Focus System Example #143
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
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 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Python-level demonstration of a focus system using McRogueFace's event callbacks.
Context
Widget focus (click-to-focus, tab cycling, keyboard routing to focused widget) is a common UI pattern but highly application-specific:
Rather than bake one specific focus model into C++, this issue creates a Python demo showing how game developers can implement focus using the engine's primitives.
Philosophy
McRogueFace provides:
Game developers combine these to create their desired focus behavior. This demo shows one approach.
Definition of Done
demos/focus_system.py- working exampleDemo Design
What This Is NOT
This is not a C++ engine feature. It's a demo showing that:
If patterns emerge that would benefit from C++ support, that's a future issue.
Dependencies
Related Issues
Implementation Details - First Pass
Available Engine Primitives
scene.on_key(key: str, action: str)drawable.on_click(x, y, button, state)drawable.on_enter(x, y, button, action)drawable.on_exit(x, y, button, action)drawable.hoveredbooldrawable.visiblebooldrawable.outlinefloatdrawable.outline_colorColorNote:
on_enter,on_exit, andhoveredare missing fromstubs/mcrfpy.pyi- should be added.Answering the Design Questions
Three Widget Types for Demo
1. FocusableGrid - WASD Movement
2. MenuIcon - Modal Activation
3. TextInput - Character Entry
Already exists in
src/scripts/text_input_widget.py- demonstrates:FocusManager Architecture
Modal Focus Stack
Demo Layout Proposal
Gaps/Issues Discovered
on_enter,on_exit,hoveredmissing fromstubs/mcrfpy.pyiFiles to Create
tests/demo/screens/focus_system_demo.py- Main demo fileFocusManagertosrc/scripts/focus_manager.pySuggested Implementation Order
Implementation Complete
Commit
b6ec0feaddstests/demo/screens/focus_system_demo.pywith a full working implementation.Checklist Status
tests/demo/screens/focus_system_demo.py- working example (810 lines)focusable=Falseparameter)Widget Types Implemented
FocusableGridTextInputWidgetMenuIconBonus Features
push_modal()/pop_modal()with Escape handlingAPI Discoveries
During implementation, found some stubs were outdated:
size=(w, h)andzoomproperty, nottile_width/tile_height/scalewalkable,transparent,entities- nocolorattributeThese should be updated in a separate stubs fix.
Screenshot
The demo renders correctly with all elements visible and focus indication working.