Skip to main content

RoutedEvent

Struct RoutedEvent 

Source
pub struct RoutedEvent<TEventArgs: ?Sized = dyn IRoutedEventArgs> { /* private fields */ }
Expand description

The identity and description of a routed event.

RoutedEvent<TEventArgs> is a routed event whose handlers receive TEventArgs; plain RoutedEvent is the untyped view of any routed event (the base class of the typed ones). Both are cheap copyable handles to the same definition and compare equal when they denote the same event; as_routed_event converts a typed handle to the untyped one.

Like property definitions, routed events are registered once per thread and live for the rest of the program; declare them with ferro_routed_event!.

Implementations§

Source§

impl RoutedEvent

Source

pub fn new_untyped<TEventArgs: IRoutedEventArgs>( name: &str, routing_strategies: RoutingStrategies, owner_type: &'static TypeInfo, ) -> RoutedEvent

Creates an untyped routed event whose args are of type TEventArgs, without registering it.

Source

pub fn register<TOwner: StaticType, TEventArgs: IRoutedEventArgs>( name: &str, routing_strategy: RoutingStrategies, ) -> &'static RoutedEvent<TEventArgs>

Registers a routed event owned by class TOwner.

Source

pub fn register_with_owner<TEventArgs: IRoutedEventArgs>( name: &str, routing_strategy: RoutingStrategies, owner_type: &'static TypeInfo, ) -> &'static RoutedEvent<TEventArgs>

Registers a routed event owned by the given type.

Source§

impl<TEventArgs: ?Sized> RoutedEvent<TEventArgs>

Source

pub fn as_routed_event(&self) -> RoutedEvent

The untyped handle of this routed event.

Source

pub fn event_args_type(&self) -> TypeId

The type of the event’s args.

Source

pub fn event_args_type_name(&self) -> &'static str

The Rust type name of the event’s args.

Source

pub fn event_args_is<T: IRoutedEventArgs>(&self) -> bool

Whether the event’s args type is T or derives from it, i.e. whether a handler taking T can be attached to the event.

Source

pub fn name(&self) -> &'static str

The name of the event.

Source

pub fn owner_type(&self) -> &'static TypeInfo

The class that registered the event.

Source

pub fn routing_strategies(&self) -> RoutingStrategies

How the event travels through the tree.

Source

pub fn has_raised_subscriptions(&self) -> bool

Whether anything is subscribed to raised, i.e. whether the event has class handlers.

Source

pub fn raised(&self) -> &'static RoutedEventObservable

Notifications of the event being raised on any element.

Source

pub fn route_finished(&self) -> &'static RouteFinishedObservable

Notifications of the event having finished one of its routes.

Source

pub fn add_class_handler_untyped( &self, target_type: &'static TypeInfo, handler: impl Fn(&Interactive, &dyn IRoutedEventArgs) + 'static, routes: RoutingStrategies, handled_events_too: bool, ) -> Rc<dyn IDisposable>

Adds a handler that is invoked for every element of type target_type (or derived from it) on the route of the event, before the handlers attached to that element.

The handler is invoked on the direct route, and on the tunnel or bubble routes selected by routes; for events that are already handled only if handled_events_too is set.

Source§

impl<TEventArgs: IRoutedEventArgs> RoutedEvent<TEventArgs>

Source

pub fn new( name: &str, routing_strategies: RoutingStrategies, owner_type: &'static TypeInfo, ) -> Self

Creates a routed event without registering it.

Source

pub fn add_class_handler<TTarget: ObjectType>( &self, handler: impl Fn(&TTarget, &TEventArgs) + 'static, ) -> Rc<dyn IDisposable>

Adds a class handler for elements of class TTarget, listening to the direct and bubble routes of unhandled events.

Source

pub fn add_class_handler_with<TTarget: ObjectType>( &self, handler: impl Fn(&TTarget, &TEventArgs) + 'static, routes: RoutingStrategies, handled_events_too: bool, ) -> Rc<dyn IDisposable>

Adds a class handler for elements of class TTarget.

See add_class_handler_untyped.

Trait Implementations§

Source§

impl<T: ?Sized> Clone for RoutedEvent<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized> Copy for RoutedEvent<T>

Source§

impl<T: ?Sized> Debug for RoutedEvent<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Display for RoutedEvent<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Eq for RoutedEvent<T>

Source§

impl<T: ?Sized> Hash for RoutedEvent<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl MarkupTyped for RoutedEvent<AccessKeyEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<AccessKeyPressedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<ContextRequestedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<DragEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<FocusChangedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<FocusChangingEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<HoldingRoutedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<KeyEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PinchEndedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PinchEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerCaptureLostEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerDeltaEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerPressedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerReleasedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PointerWheelEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PullGestureEndedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<PullGestureEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<RoutedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<ScrollGestureEndedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<ScrollGestureEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<ScrollGestureInertiaStartingEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<SwipeGestureEndedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<SwipeGestureEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<TappedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<TextInputEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<TextInputMethodClientRequeryRequestedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent<TextInputMethodClientRequestedEventArgs>

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl MarkupTyped for RoutedEvent

Source§

const MARKUP: &'static MarkupType

The markup metadata of the type.
Source§

impl<T: ?Sized, U: ?Sized> PartialEq<RoutedEvent<U>> for RoutedEvent<T>

Source§

fn eq(&self, other: &RoutedEvent<U>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<TEventArgs = dyn IRoutedEventArgs> !RefUnwindSafe for RoutedEvent<TEventArgs>

§

impl<TEventArgs = dyn IRoutedEventArgs> !Send for RoutedEvent<TEventArgs>

§

impl<TEventArgs = dyn IRoutedEventArgs> !Sync for RoutedEvent<TEventArgs>

§

impl<TEventArgs = dyn IRoutedEventArgs> !UnwindSafe for RoutedEvent<TEventArgs>

§

impl<TEventArgs> Freeze for RoutedEvent<TEventArgs>
where PhantomData<fn(&TEventArgs)>: Freeze, TEventArgs: ?Sized,

§

impl<TEventArgs> Unpin for RoutedEvent<TEventArgs>
where PhantomData<fn(&TEventArgs)>: Unpin, TEventArgs: ?Sized,

§

impl<TEventArgs> UnsafeUnpin for RoutedEvent<TEventArgs>
where PhantomData<fn(&TEventArgs)>: UnsafeUnpin, TEventArgs: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PropertyValue for T
where T: Clone + PartialEq + 'static,

Source§

impl<T> ResourceKeyObject for T
where T: Eq + Hash + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn dyn_eq(&self, other: &(dyn ResourceKeyObject + 'static)) -> bool

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Source§

fn key_type_name(&self) -> &'static str

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.