[][src]Trait unsegen::input::Behavior

pub trait Behavior {
    fn input(self, input: Input) -> Option<Input>;
}

Something that reacts to input and possibly consumes it.

An inplementor is free to check the Input for arbitrary criteria and return the input if not consumed. Note that the implementor should not change the input event in that case.

If the implementor somehow reacts to the input, it is generally a good idea to "consume" the value by returning None. This makes sure that subsequent Behaviors will not act.

Another thing of note is that a Behavior is generally constructed on the fly and consumed in the input function! For specialised behavior that does not fit into the often used abstractions defined in this module (Scrollable, Writable, Navigatable, ...) the easiest way to construct a behavior is either using a FnOnce(Input) -> Option<Input> where the implementor has to decide whether the input matches the desired criteria or using a pair (ToEvent, FnOnce()) where the function is only iff the Input to be processed matches the provided Event-like thing.

Required methods

fn input(self, input: Input) -> Option<Input>

Loading content...

Implementations on Foreign Types

impl<E: ToEvent, F: FnOnce()> Behavior for (E, F)[src]

impl<E: ToEvent + Clone, F: FnOnce(), '_> Behavior for (&'_ [E], F)[src]

Loading content...

Implementors

impl<'a, 'b, 'c, 'd: 'a, C: ContainerProvider + 'a + 'b> Behavior for ActiveContainerBehavior<'a, 'b, 'c, 'd, C>[src]

Pass input on to the currently active container.

impl<'a, E: Editable> Behavior for EditBehavior<'a, E>[src]

impl<'a, N: Navigatable + 'a> Behavior for NavigateBehavior<'a, N>[src]

impl<'a, R: TableRow + 'static> Behavior for CurrentCellBehavior<'a, R>[src]

impl<'a, S: Scrollable> Behavior for ScrollBehavior<'a, S>[src]

impl<'a, W: Writable + 'a> Behavior for WriteBehavior<'a, W>[src]

impl<F: FnOnce(Input) -> Option<Input>> Behavior for F[src]

Loading content...