Mouse Event Types
Rezi handles three primary mouse event types:- Click
- Scroll
- Drag
Mouse button press and release:Interactive widgets (buttons, links, etc.) emit
press actions on click.Scrollable Containers
Enable scrolling on containers withoverflow: "scroll":
Scroll Event Handling
Virtual Lists
Virtual lists handle mouse wheel scrolling automatically:Clickable Widgets
All interactive widgets support mouse clicks:id emits the appropriate action (press, toggle, etc.).
Raw Mouse Events
Access raw mouse events for custom handling:Mouse Event Structure
Canvas Mouse Interaction
Capture mouse events on canvas widgets:Drag and Drop
Implement drag interactions with mouse state:Terminal Mouse Support
Rezi auto-detects mouse support:Split Pane Resizing
Split panes support mouse-based resizing:Scroll Wheel Routing
Scroll events automatically route to the nearest scrollable ancestor:Horizontal Scrolling
Support horizontal mouse wheel (shift+scroll):Mouse Button Detection
Distinguish between left, middle, and right clicks:Best Practices
Keyboard Fallback
Always provide keyboard alternatives. Not all terminals support mouse events. Interactive widgets should work with Tab + Enter.
Scroll Targets
Use
overflow: "scroll" on containers that should handle wheel events. Rezi routes events to the nearest scrollable ancestor.Virtual Lists
For long lists, use
ui.virtualList instead of manual scroll handling. It’s optimized for large datasets.Visual Feedback
Provide hover states or cursor changes when possible. Terminal capabilities vary, so don’t rely solely on mouse feedback.
Next Steps
Animation
Add smooth transitions and animations to your UI
Routing
Implement page navigation with the router