pub trait Element {
// Provided methods
fn draw(&self, _rect: Rect, _frame: &mut Frame<'_>) { ... }
fn on_key(&self, _event: KeyEvent) { ... }
fn on_mouse(&self, _rect: Rect, _event: MouseEvent) { ... }
}
Expand description
A rendered component.
Once a Component
is rendered, it now can be drawn (through draw
) or it
can handle a key event (through on_key
).
Drawing
Intuitive internally uses tui in order to draw to the terminal. The Rect
and Frame
structures are re-exports from tui.
Handling Keys
Typically, structures that implement Element
do not have any State
.
Usually, an Element
will contain an on_key
field which has captured any
state that could be mutated, and then the Element
will delegate key events
to its on_key
field. See the Section
source for an example of this.