pub trait KbgpEguiUiCtxExt {
// Required methods
fn kbgp_clear_input(&self);
fn kbgp_set_focus_label<T: 'static + Send + Sync>(&self, label: T);
fn kbgp_user_action<T: 'static + Clone>(&self) -> Option<T>;
fn kbgp_user_action_released<T: 'static + Clone>(&self) -> Option<T>;
}
Expand description
Extensions for egui’s UI
and Context to activate KBGP’s functionality.
Required Methods§
Sourcefn kbgp_clear_input(&self)
fn kbgp_clear_input(&self)
Needs to be called when triggering state transition from egui.
Otherwise, the same player input that triggered the transition will be applied again to the GUI in the new state.
Sourcefn kbgp_set_focus_label<T: 'static + Send + Sync>(&self, label: T)
fn kbgp_set_focus_label<T: 'static + Send + Sync>(&self, label: T)
Focus on the widget that called kbgp_focus_label
with the same label.
This will only happen on the next frame.
Sourcefn kbgp_user_action<T: 'static + Clone>(&self) -> Option<T>
fn kbgp_user_action<T: 'static + Clone>(&self) -> Option<T>
Check if the player pressed a user action button.
Note that if the focus is on a widget that handles a user action, it will be reported both
by that widget’s kbgp_user_action
or
kbgp_activated
and by this method.
match ui.kbgp_user_action() {
None => {}
Some(MyUserAction::Action1) => println!("User action 1"),
Some(MyUserAction::Action2) => println!("User action 2"),
}
Sourcefn kbgp_user_action_released<T: 'static + Clone>(&self) -> Option<T>
fn kbgp_user_action_released<T: 'static + Clone>(&self) -> Option<T>
Similar to kbgp_user_action
, but only returns Some
when the
key/button is released.
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.