RoutedEvent
struct · ferroui-base · v0.5.0
struct RoutedEvent<TEventArgs: ?Sized = dyn IRoutedEventArgs>
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!.
Members
new_untypedregisterregister_with_owneras_routed_eventevent_args_typeevent_args_type_nameevent_args_isnameowner_typerouting_strategieshas_raised_subscriptionshas_instance_handlersraisedroute_finishedadd_class_handler_untypednewadd_class_handleradd_class_handler_with
new_untyped
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.
register
fn register<TOwner: StaticType, TEventArgs: IRoutedEventArgs>(name: &str, routing_strategy: RoutingStrategies) -> &'static RoutedEvent<TEventArgs>
Registers a routed event owned by class TOwner.
register_with_owner
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.
as_routed_event
fn as_routed_event(self: &Self) -> RoutedEvent
The untyped handle of this routed event.
event_args_type
fn event_args_type(self: &Self) -> TypeId
The type of the event's args.
event_args_type_name
fn event_args_type_name(self: &Self) -> &'static str
The Rust type name of the event's args.
event_args_is
fn event_args_is<T: IRoutedEventArgs>(self: &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.
name
fn name(self: &Self) -> &'static str
The name of the event.
owner_type
fn owner_type(self: &Self) -> &'static TypeInfo
The class that registered the event.
routing_strategies
fn routing_strategies(self: &Self) -> RoutingStrategies
How the event travels through the tree.
has_raised_subscriptions
fn has_raised_subscriptions(self: &Self) -> bool
Whether anything is subscribed to raised, i.e.
whether the event has class handlers.
has_instance_handlers
fn has_instance_handlers(self: &Self) -> bool
Whether any interactive of the thread has an instance handler of the event. With no instance handler and no class handler a raise has nothing to visit, so its route is empty whatever the tree is.
raised
fn raised(self: &Self) -> &'static RoutedEventObservable
Notifications of the event being raised on any element.
route_finished
fn route_finished(self: &Self) -> &'static RouteFinishedObservable
Notifications of the event having finished one of its routes.
add_class_handler_untyped
fn add_class_handler_untyped(self: &Self, target_type: &'static TypeInfo, handler: impl Fn(&Interactive, &dyn IRoutedEventArgs) -> () + 'static, routes: RoutingStrategies, handled_events_too: bool) -> Subscription
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.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the event (what a
class handler registered once for a class does).
new
fn new(name: &str, routing_strategies: RoutingStrategies, owner_type: &'static TypeInfo) -> Self
Creates a routed event without registering it.
add_class_handler
fn add_class_handler<TTarget: ObjectType>(self: &Self, handler: impl Fn(&TTarget, &TEventArgs) -> () + 'static) -> Subscription
Adds a class handler for elements of class TTarget, listening to
the direct and bubble routes of unhandled events.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the event.
add_class_handler_with
fn add_class_handler_with<TTarget: ObjectType>(self: &Self, handler: impl Fn(&TTarget, &TEventArgs) -> () + 'static, routes: RoutingStrategies, handled_events_too: bool) -> Subscription
Adds a class handler for elements of class TTarget.
See add_class_handler_untyped:
dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the event.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneCopyPartialEq<RoutedEvent<U>>EqHashDebugDisplayMarkupTyped
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.