Skip to main content

Component

Trait Component 

Source
pub trait Component<CID, CA, CS, CM>: MockComponent + MockProps
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,
{ // Provided methods fn on_event( &mut self, _event: EzEvent<CID, CM>, state: &mut State<CS>, ) -> Vec<EzEvent<CID, CM>> { ... } fn init(&mut self, state: &mut State<CS>) -> Vec<EzEvent<CID, CM>> { ... } fn tick(&mut self, state: &mut State<CS>) -> Vec<EzEvent<CID, CM>> { ... } fn focusable(&self) -> bool { ... } fn legend(&self) -> Option<Legend> { ... } fn capture_focus(&mut self, forward: bool) -> bool { ... } }
Expand description

A type to describe a concrete component. In your app, every component should have it’s own struct implementing this trait.

Provided Methods§

Source

fn on_event( &mut self, _event: EzEvent<CID, CM>, state: &mut State<CS>, ) -> Vec<EzEvent<CID, CM>>

Method to implement to handle events. The component will receive any event if it is focused; but only events it is subscribed to otherwise.

Source

fn init(&mut self, state: &mut State<CS>) -> Vec<EzEvent<CID, CM>>

Method called on first tick only.

Source

fn tick(&mut self, state: &mut State<CS>) -> Vec<EzEvent<CID, CM>>

Method called on every tick. You should implement it only if you need to save a reference to the state or if your business logic needs to execute some code on a regular basis.

Source

fn focusable(&self) -> bool

Whether the component is focusable or not.

Source

fn legend(&self) -> Option<Legend>

Get the component’s hotkeys legend.

Source

fn capture_focus(&mut self, forward: bool) -> bool

Returns true if the focus is handled internally. Let’s say this component has two inner focusable area:

  • on first call to capture_focus with forward = true, it’s your responsibility to focus the first area and return false.
  • on second call same; focus the second area and return false.
  • on third call, unfocus all area and return false so the view can cycle to the next component.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for AppStateCpt<CS>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for Legends<CA, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for LogsViewer<CA, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for RenderIndicatorCpt<CA, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for TickIndicatorCpt<CA, CM>
where CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for CheckboxInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for DateTimeInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for FormCpt<FID, CID, CA, CS, CM>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for NumberInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for RangeInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for SelectInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,

Source§

impl<FID, CID, CA, CS, CM> Component<CID, CA, CS, CM> for TextInputCpt<FID>
where FID: EzCptIds, CID: EzCptIds, CA: EzArgs, CS: EzState, CM: EzMsg,