FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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!.

    View source

    Members

    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.

    Source

    register

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

    Registers a routed event owned by class TOwner.

    Source

    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.

    Source

    as_routed_event

    fn as_routed_event(self: &Self) -> RoutedEvent
    

    The untyped handle of this routed event.

    Source

    event_args_type

    fn event_args_type(self: &Self) -> TypeId
    

    The type of the event's args.

    Source

    event_args_type_name

    fn event_args_type_name(self: &Self) -> &'static str
    

    The Rust type name of the event's args.

    Source

    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.

    Source

    name

    fn name(self: &Self) -> &'static str
    

    The name of the event.

    Source

    owner_type

    fn owner_type(self: &Self) -> &'static TypeInfo
    

    The class that registered the event.

    Source

    routing_strategies

    fn routing_strategies(self: &Self) -> RoutingStrategies
    

    How the event travels through the tree.

    Source

    has_raised_subscriptions

    fn has_raised_subscriptions(self: &Self) -> bool
    

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

    Source

    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.

    Source

    raised

    fn raised(self: &Self) -> &'static RoutedEventObservable
    

    Notifications of the event being raised on any element.

    Source

    route_finished

    fn route_finished(self: &Self) -> &'static RouteFinishedObservable
    

    Notifications of the event having finished one of its routes.

    Source

    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).

    Source

    new

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

    Creates a routed event without registering it.

    Source

    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.

    Source

    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.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ResourceKeyObject
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Copy
    • PartialEq<RoutedEvent<U>>
    • Eq
    • Hash
    • Debug
    • Display
    • MarkupTyped

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.