Skip to main content

Widget

Trait Widget 

Source
pub trait Widget {
    // Required method
    fn render(&self, area: Rect, buf: &mut Buffer);

    // Provided methods
    fn focusable(&self) -> bool { ... }
    fn height_hint(&self, _width: u16) -> Option<u16> { ... }
    fn width_hint(&self) -> Option<u16> { ... }
}
Expand description

Trait for custom character-cell widgets.

Implement this trait to create widgets that render directly to the terminal buffer. Use View::custom() to wrap your widget in a View.

Required Methods§

Source

fn render(&self, area: Rect, buf: &mut Buffer)

Render the widget into the given area of the buffer.

Provided Methods§

Source

fn focusable(&self) -> bool

Whether this widget is focusable (receives keyboard input).

Source

fn height_hint(&self, _width: u16) -> Option<u16>

Hint for the widget’s preferred height given a width. Returns None if the widget has no preferred height.

Source

fn width_hint(&self) -> Option<u16>

Hint for the widget’s preferred width. Returns None if the widget has no preferred width.

Implementors§