Skip to main content

InputContextAppExt

Trait InputContextAppExt 

Source
pub trait InputContextAppExt {
    // Required method
    fn add_input_context_to<S: ScheduleLabel + Default, C: Component>(
        &mut self,
    ) -> &mut Self;

    // Provided method
    fn add_input_context<C: Component>(&mut self) -> &mut Self { ... }
}
Expand description

An extension trait for App to assign input to components.

Required Methods§

Source

fn add_input_context_to<S: ScheduleLabel + Default, C: Component>( &mut self, ) -> &mut Self

Like Self::add_input_context, but allows specifying the schedule in which the context’s actions will be evaluated.

For example, if your game logic runs inside FixedMain, you can set the schedule to FixedPreUpdate. This way, if the schedule runs multiple times per frame, events like Start or Complete will be triggered only once per schedule run.

Provided Methods§

Source

fn add_input_context<C: Component>(&mut self) -> &mut Self

Registers type C as an input context, whose actions will be evaluated during PreUpdate.

Action evaluation follows these steps:

This logic may look complicated, but you don’t have to memorize it. It behaves surprisingly intuitively.

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 InputContextAppExt for App

Source§

fn add_input_context_to<S: ScheduleLabel + Default, C: Component>( &mut self, ) -> &mut Self

Implementors§