pub struct CommandArgs {
pub timestamp: DInstant,
pub param: Option<CommandParam>,
pub scope: CommandScope,
pub target: Option<WidgetPath>,
pub enabled: bool,
pub propagation: EventPropagationHandle,
}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.
target: Option<WidgetPath>Target widget.
- If the scope is
Appthis isNone. - If the scope is
Windowthis is the window root widget, if the window was found. - If the scope is
Widgetthis is the widget, if it was found.
enabled: boolIf the command 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.
Note that this is the Command::is_enabled value, it is true id any handle is enabled,
the local handler might still be disabled.
propagation: EventPropagationHandlePropagation handle associated with this event instance.
Cloned arguments share the same handle, some arguments may also share the handle of another event if they share the same cause.
Implementations§
Source§impl CommandArgs
impl CommandArgs
Sourcepub fn new(
timestamp: impl Into<DInstant>,
propagation: EventPropagationHandle,
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
target: impl Into<Option<WidgetPath>>,
enabled: impl Into<bool>,
) -> CommandArgs
pub fn new( timestamp: impl Into<DInstant>, propagation: EventPropagationHandle, param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, target: impl Into<Option<WidgetPath>>, enabled: impl Into<bool>, ) -> CommandArgs
Sourcepub fn try_new(
timestamp: impl Into<DInstant>,
propagation: EventPropagationHandle,
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
target: impl Into<Option<WidgetPath>>,
enabled: impl Into<bool>,
) -> Result<CommandArgs, Txt>
pub fn try_new( timestamp: impl Into<DInstant>, propagation: EventPropagationHandle, param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, target: impl Into<Option<WidgetPath>>, enabled: impl Into<bool>, ) -> Result<CommandArgs, Txt>
New args from values that convert into the argument types.
Returns an error if the constructed arguments are invalid.
Sourcepub fn now(
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
target: impl Into<Option<WidgetPath>>,
enabled: impl Into<bool>,
) -> CommandArgs
pub fn now( param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, target: impl Into<Option<WidgetPath>>, enabled: impl Into<bool>, ) -> CommandArgs
Sourcepub fn try_now(
param: impl Into<Option<CommandParam>>,
scope: impl Into<CommandScope>,
target: impl Into<Option<WidgetPath>>,
enabled: impl Into<bool>,
) -> Result<CommandArgs, Txt>
pub fn try_now( param: impl Into<Option<CommandParam>>, scope: impl Into<CommandScope>, target: impl Into<Option<WidgetPath>>, enabled: impl Into<bool>, ) -> Result<CommandArgs, Txt>
Arguments for event that happened now (INSTANT.now).
Returns an error if the constructed arguments are invalid.
Sourcepub fn assert_valid(&self)
pub fn assert_valid(&self)
Panics if the arguments are invalid.
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 scope_matches(&self, direct_only: bool, scope: CommandScope) -> bool
pub fn scope_matches(&self, direct_only: bool, scope: CommandScope) -> bool
If direct_only is enabled only matches exact command scope matches,
otherwise the app scope matches all args, the window scope matches all events for the window
or widgets in the window and the widget scope matches the widget and all descendants.
Trait Implementations§
Source§impl AnyEventArgs for CommandArgs
impl AnyEventArgs for CommandArgs
Source§fn is_in_target(&self, id: WidgetId) -> bool
fn is_in_target(&self, id: WidgetId) -> bool
Broadcast to all if the scope is App, otherwise if is in target.
Source§fn propagation(&self) -> &EventPropagationHandle
fn propagation(&self) -> &EventPropagationHandle
Source§fn clone_boxed(&self) -> Box<dyn AnyEventArgs>
fn clone_boxed(&self) -> Box<dyn AnyEventArgs>
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
Source§impl PartialEq for CommandArgs
impl PartialEq for CommandArgs
impl EventArgs for CommandArgs
impl StructuralPartialEq 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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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> 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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> 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