Raxol.Core.KeyboardNavigator (Raxol v2.0.1)
View SourceRefactored KeyboardNavigator that delegates to GenServer implementation.
This module provides the same API as the original KeyboardNavigator but uses a supervised GenServer instead of the Process dictionary for state management.
Migration Notice
This module is a drop-in replacement for Raxol.Core.KeyboardNavigator.
All functions maintain backward compatibility while providing improved
fault tolerance and functional programming patterns.
Benefits over Process Dictionary
- Supervised state management with fault tolerance
- Pure functional navigation logic
- Spatial navigation with efficient neighbor calculation
- Navigation history stack for back navigation
- Group-based navigation support
- Better debugging and testing capabilities
- No global state pollution
New Features
- Focus stack for back navigation
- Component grouping for logical navigation
- Enhanced spatial navigation algorithms
- Configurable navigation strategies
Summary
Functions
Clear all navigation paths.
Clear all spatial mappings.
Configure keyboard navigation behavior.
Define explicit navigation paths between components.
Ensures the Keyboard Navigator server is started.
Gets the current configuration.
Gets navigation paths.
Gets the spatial map.
Handle keyboard events for navigation.
Initialize the keyboard navigator.
Pop and return to the previous focus.
Push current focus to the navigation stack.
Register component positions for spatial navigation.
Register a component to a navigation group.
Reset the navigator to initial state.
Unregister a component from a navigation group.
Functions
Clear all spatial mappings.
Configure keyboard navigation behavior.
Options
:next_key- Key to move to next element (default::tab):previous_key- Key to move to previous element (default::tabwith shift):activate_keys- Keys to activate elements (default:[:enter, :space]):dismiss_key- Key to dismiss or go back (default::escape):arrow_navigation- Enable arrow key navigation (default:true):vim_keys- Enable vim-style navigation with h,j,k,l (default:false):group_navigation- Enable group-based navigation (default:true):spatial_navigation- Enable spatial navigation for grid layouts (default:false):tab_navigation- Enable tab-based navigation (default:true)
Ensures the Keyboard Navigator server is started.
Gets the current configuration.
For backward compatibility with Process dictionary version.
Gets the spatial map.
For backward compatibility with Process dictionary version.
Handle keyboard events for navigation.
This function is called by the EventManager when keyboard events occur. The actual processing is delegated to the server.
Initialize the keyboard navigator.
This registers event handlers for keyboard navigation.
Pop and return to the previous focus.
Returns the component ID that was restored, or nil if stack was empty.
Push current focus to the navigation stack.
Useful for modal dialogs or nested navigation contexts.
Register component positions for spatial navigation.
This allows arrow keys to navigate components based on their physical layout.
Register a component to a navigation group.
Groups allow logical navigation between related components.
Reset the navigator to initial state.
Unregister a component from a navigation group.