pub trait FocusableWidget {
// Required methods
fn id(&self) -> WidgetId;
fn handle_key(&self, key: KeyEvent) -> InputResult;
fn handle_operation(
&mut self,
op: &Operation,
settings: &Settings,
) -> Option<Event>;
fn render(
&self,
frame: &mut Frame<'_>,
area: Rect,
focused: bool,
theme: &Theme,
);
// Provided methods
fn handle_mouse(&self, _mouse: MouseEvent, _area: Rect) -> InputResult { ... }
fn captures_tab(&self) -> bool { ... }
fn focusable(&self) -> bool { ... }
}Expand description
A widget that can receive focus, handle input, and render itself.
This is NOT a replacement for ratatui’s Widget trait. It is a
higher-level composition trait used by views to manage interactive
sub-components. Widgets still use ratatui primitives internally.
Required Methods§
Sourcefn handle_key(&self, key: KeyEvent) -> InputResult
fn handle_key(&self, key: KeyEvent) -> InputResult
Handle a key event while this widget has focus.
Returns ops + consumed flag. Must not mutate self.
Provided Methods§
Sourcefn handle_mouse(&self, _mouse: MouseEvent, _area: Rect) -> InputResult
fn handle_mouse(&self, _mouse: MouseEvent, _area: Rect) -> InputResult
Handle a mouse event. area is the widget’s last rendered rect.
Sourcefn captures_tab(&self) -> bool
fn captures_tab(&self) -> bool
Whether this widget wants to capture Tab key presses, preventing
the view from using Tab for focus cycling.
Default: false. Override for multi-line text inputs.