pub struct CommandArgs {
pub timestamp: DInstant,
pub param: Option<CommandParam>,
pub scope: CommandScope,
pub enabled: bool,
/* private fields */
}Expand description
Event args for command events.
Fields§
§timestamp: DInstantInstant the event happened.
param: Option<CommandParam>Optional parameter for the command handler.
scope: CommandScopeScope of command that notified.
enabled: boolIf the command handle was enabled when the command notified.
If false the command primary action must not run, but a secondary “disabled interaction”
that indicates what conditions enable the command is recommended.
Implementations§
Source§impl CommandArgs
impl CommandArgs
Sourcepub fn new(
timestamp: impl Into<DInstant>,
propagation_handle: EventPropagationHandle,
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
enabled: impl Into<bool>,
) -> Self
pub fn new( timestamp: impl Into<DInstant>, propagation_handle: EventPropagationHandle, param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, enabled: impl Into<bool>, ) -> Self
New args from values that convert into the argument types.
Sourcepub fn now(
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
enabled: impl Into<bool>,
) -> Self
pub fn now( param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, enabled: impl Into<bool>, ) -> Self
Arguments for event that happened now (INSTANT.now).
Source§impl CommandArgs
impl CommandArgs
Sourcepub fn param<T: Any>(&self) -> Option<&T>
pub fn param<T: Any>(&self) -> Option<&T>
Returns a reference to a parameter of T if parameter is set to a value of T.
Sourcepub fn handle_enabled<F, R>(
&self,
local_handle: &CommandHandle,
handler: F,
) -> Option<R>where
F: FnOnce(&Self) -> R,
pub fn handle_enabled<F, R>(
&self,
local_handle: &CommandHandle,
handler: F,
) -> Option<R>where
F: FnOnce(&Self) -> R,
Call handler if propagation is not stopped and the command and local handler are enabled. Stops propagation
after handler is called.
This is the default behavior of commands, when a command has a handler it is relevant in the context, and overwrites lower priority handlers, but if the handler is disabled the command primary action is not run.
Returns the handler result if it was called.
Trait Implementations§
Source§impl AnyEventArgs for CommandArgs
impl AnyEventArgs for CommandArgs
Source§fn delivery_list(&self, list: &mut UpdateDeliveryList)
fn delivery_list(&self, list: &mut UpdateDeliveryList)
Broadcast to all widget subscribers for CommandScope::App. Targets the window root for
CommandScope::Window if found. Target ancestors and widget for CommandScope::Widget, if it is found.
Source§fn clone_any(&self) -> Box<dyn AnyEventArgs>
fn clone_any(&self) -> Box<dyn AnyEventArgs>
Source§fn propagation(&self) -> &EventPropagationHandle
fn propagation(&self) -> &EventPropagationHandle
Source§impl Clone for CommandArgs
impl Clone for CommandArgs
Source§fn clone(&self) -> CommandArgs
fn clone(&self) -> CommandArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommandArgs
impl Debug for CommandArgs
Auto Trait Implementations§
impl Freeze for CommandArgs
impl !RefUnwindSafe for CommandArgs
impl Send for CommandArgs
impl Sync for CommandArgs
impl Unpin for CommandArgs
impl !UnwindSafe for CommandArgs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more