pub trait Widget: 'static + Debug + Send + Sync {
    type Command: Debug + Send + Sync;
    type Event: Debug + Send + Sync;

    const CLASS: &'static str;
    const FOCUSABLE: bool;

    fn classes() -> Classes { ... }
    fn receive_event(&mut self, event: Self::Event, context: &Context<Self>) { ... }
    fn text_color(style: &Style) -> Option<&ColorPair> { ... }
    fn background_color(style: &Style) -> Option<&ColorPair> { ... }
    fn map<OW, F, R>(
        widget_id: &WidgetId,
        context: &Context<Self>,
        with_fn: F
    ) -> Option<R>
    where
        OW: Widget,
        F: FnOnce(&OW, &Context<OW>) -> R
, { ... } fn map_mut<OW, F, R>(
        widget_id: &WidgetId,
        context: &Context<Self>,
        with_fn: F
    ) -> Option<R>
    where
        OW: Widget,
        F: FnOnce(&mut OW, &Context<OW>) -> R
, { ... } }
Expand description

A graphical user interface element.

Required Associated Types

Widgets may need to communicate with transmogrifier implementations. This type is the type that can be sent to a transmogrifier.

The type of the event that any Transmogrifier for this widget to use.

Required Associated Constants

The unique class name for this widget. Must not conflict with any other widgets in use. Widget authors should prefix their widget names to ensure no conflicts. For example, the gooey-widgets crate prefixes all of the CLASS constants with gooey-.

When true, the control is able to receive focus through focus advancement, most commonly done when using the tab key.

Provided Methods

Returns all classes that apply styles for this widget.

Called when an event from the transmogrifier was received.

Returns the effective text color for the given style.

Returns the effective background color for the given style.

Invokes with_fn with the widget widget_id and a Context. Returns the result.

Returns None if OW does not match the type of the widget contained.

Invokes with_fn with the widget widget_id and a Context. Returns the result.

Returns None if OW does not match the type of the widget contained.

Implementors