Interactive
struct · ferroui-base · v0.5.0
struct Interactive
Base class for objects that raise routed events.
Members
TYPEto_refinteractive_parentDEFAULT_ROUTESconstructnewadd_handleradd_handler_withadd_handler_asadd_handler_untypedadd_route_handlerremove_handlerraise_eventbuild_event_routeadd_disposable_handleradd_disposable_handler_withget_interactive_parentget_observableget_observable_with
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<Interactive>
Returns a strong reference to this object.
interactive_parent
fn interactive_parent(self: &Self) -> Option<Ref<Interactive>>
The interactive parent of the object for bubbling and tunneling events. By default this is the visual parent, when it is an interactive.
DEFAULT_ROUTES
const DEFAULT_ROUTES: RoutingStrategies
The routes a handler listens to unless specified otherwise: the direct and bubble routes.
construct
fn construct() -> Self
Creates the class data; see crate::FerroObject::construct.
new
fn new() -> Ref<Self>
add_handler
fn add_handler<TEventArgs: IRoutedEventArgs>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: impl Fn(&Interactive, &TEventArgs) -> () + 'static) -> RoutedEventHandlerToken
Adds a handler for a routed event, listening to the direct and bubble routes of unhandled events.
Returns a token for remove_handler.
add_handler_with
fn add_handler_with<TEventArgs: IRoutedEventArgs>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: impl Fn(&Interactive, &TEventArgs) -> () + 'static, routes: RoutingStrategies, handled_events_too: bool) -> RoutedEventHandlerToken
Adds a handler for a routed event.
routes selects the routing strategies to listen to, and
handled_events_too whether the handler is also invoked for events
that are already handled. The handler receives the element it is
attached to and the event args.
add_handler_as
fn add_handler_as<THandlerArgs: IRoutedEventArgs, TEventArgs: ?Sized>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: impl Fn(&Interactive, &THandlerArgs) -> () + 'static, routes: RoutingStrategies, handled_events_too: bool) -> RoutedEventHandlerToken
Adds a handler written against args type THandlerArgs to any
routed event whose args type is THandlerArgs or derives from it.
This is how a handler taking the base
RoutedEventArgs is attached to an event
with more specific args, and how handlers are attached to an untyped
RoutedEvent.
Panics if the event's args type does not derive from THandlerArgs.
add_handler_untyped
fn add_handler_untyped<TEventArgs: ?Sized>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: MarkupDelegate, routes: RoutingStrategies, handled_events_too: bool) -> RoutedEventHandlerToken
Adds an untyped handler for a routed event: what markup attaches for an event attribute.
The handler is called with two untyped values: the element it is
attached to (a Ref<Interactive>) and a shared handle to the event
args (an Rc<dyn IRoutedEventArgs>, see
IRoutedEventArgs::share). The handle refers to the live args:
marking it as handled marks the event as handled for the handlers
further along the route.
add_route_handler
fn add_route_handler<TEventArgs: ?Sized>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: RouteHandler, routes: RoutingStrategies, handled_events_too: bool) -> RoutedEventHandlerToken
Adds an already adapted handler for a routed event.
remove_handler
fn remove_handler<TEventArgs: ?Sized>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: RoutedEventHandlerToken) -> bool
Removes a handler for a routed event. Returns whether the handler was attached.
raise_event
fn raise_event(self: &Self, e: &dyn IRoutedEventArgs)
Raises a routed event.
Panics if the args have no routed event.
build_event_route
fn build_event_route<TEventArgs: ?Sized>(self: &Self, e: &RoutedEvent<TEventArgs>) -> EventRoute
Builds an event route for a routed event: the handlers the event would visit if raised on this object, in bubbling order.
add_disposable_handler
fn add_disposable_handler<TEventArgs: IRoutedEventArgs>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: impl Fn(&Interactive, &TEventArgs) -> () + 'static) -> Subscription
Adds a handler for a routed event (direct and bubble routes,
unhandled events) and returns the guard of the handler: dropping it
removes the handler; Subscription::detach keeps it for the life
of the object.
add_disposable_handler_with
fn add_disposable_handler_with<TEventArgs: IRoutedEventArgs>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, handler: impl Fn(&Interactive, &TEventArgs) -> () + 'static, routes: RoutingStrategies, handled_events_too: bool) -> Subscription
Adds a handler for a routed event and returns the guard of the
handler: dropping it removes the handler; Subscription::detach
keeps it for the life of the object.
get_interactive_parent
fn get_interactive_parent(self: &Self) -> Option<Ref<Interactive>>
The interactive parent of the object for bubbling and tunneling events.
get_observable
fn get_observable<TEventArgs: IRoutedEventArgs + Clone>(self: &Self, routed_event: &RoutedEvent<TEventArgs>) -> Rc<dyn IObservable<TEventArgs>>
Gets an observable for a routed event (direct and bubble routes, unhandled events).
See get_observable_with.
get_observable_with
fn get_observable_with<TEventArgs: IRoutedEventArgs + Clone>(self: &Self, routed_event: &RoutedEvent<TEventArgs>, routes: RoutingStrategies, handled_events_too: bool) -> Rc<dyn IObservable<TEventArgs>>
Gets an observable for a routed event.
Observers receive a copy of the args of every raise. The copy reflects the routing state at the time of the notification; marking the copy as handled does not affect the event being routed. Use a handler for that.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyErasedDestructorIntoEitherDerefUpcast<T>Upcast<Interactive>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleFerroObjectImplStyledElementImplVisualImplLayoutableImplInteractiveImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.