Struct zng_app::event::CommandArgs
source · 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>,
) -> 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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