Trait Component

Source
pub trait Component: 'static {
    type State: State;
    type Message;

    const TICKS: bool = true;

    // Provided methods
    fn on_key(
        &mut self,
        key: KeyEvent,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_mount(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_unmount(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_blur(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_focus(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_mouse(
        &mut self,
        mouse: MouseEvent,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_tick(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
        dt: Duration,
    ) { ... }
    fn on_message(
        &mut self,
        message: Self::Message,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_resize(
        &mut self,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn on_event(
        &mut self,
        event: &mut UserEvent<'_>,
        state: &mut Self::State,
        children: Children<'_, '_>,
        context: Context<'_, '_, Self::State>,
    ) { ... }
    fn accept_focus(&self) -> bool { ... }
}

Provided Associated Constants§

Source

const TICKS: bool = true

Required Associated Types§

Provided Methods§

Source

fn on_key( &mut self, key: KeyEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_mount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_unmount( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_blur( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_focus( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_mouse( &mut self, mouse: MouseEvent, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_tick( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, dt: Duration, )

Source

fn on_message( &mut self, message: Self::Message, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_resize( &mut self, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn on_event( &mut self, event: &mut UserEvent<'_>, state: &mut Self::State, children: Children<'_, '_>, context: Context<'_, '_, Self::State>, )

Source

fn accept_focus(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Component for ()

Implementors§