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: DInstant
Instant the event happened.
param: Option<CommandParam>
Optional parameter for the command handler.
scope: CommandScope
Scope of command that notified.
enabled: bool
If 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>,
) -> CommandArgs
pub fn new( timestamp: impl Into<DInstant>, propagation_handle: EventPropagationHandle, param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, enabled: impl Into<bool>, ) -> CommandArgs
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>,
) -> CommandArgs
pub fn now( param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, enabled: impl Into<bool>, ) -> CommandArgs
Arguments for event that happened now (INSTANT.now
).
source§impl CommandArgs
impl CommandArgs
sourcepub fn param<T>(&self) -> Option<&T>where
T: Any,
pub fn param<T>(&self) -> Option<&T>where
T: Any,
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(&CommandArgs) -> R,
pub fn handle_enabled<F, R>(
&self,
local_handle: &CommandHandle,
handler: F,
) -> Option<R>where
F: FnOnce(&CommandArgs) -> 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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