FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Interactive

    struct · ferroui-base · v0.5.0

    struct Interactive
    

    Base class for objects that raise routed events.

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<Interactive>
    

    Returns a strong reference to this object.

    Source

    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.

    Source

    DEFAULT_ROUTES

    const DEFAULT_ROUTES: RoutingStrategies
    

    The routes a handler listens to unless specified otherwise: the direct and bubble routes.

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see crate::FerroObject::construct.

    Source

    new

    fn new() -> Ref<Self>
    

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    raise_event

    fn raise_event(self: &Self, e: &dyn IRoutedEventArgs)
    

    Raises a routed event.

    Panics if the args have no routed event.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    get_interactive_parent

    fn get_interactive_parent(self: &Self) -> Option<Ref<Interactive>>
    

    The interactive parent of the object for bubbling and tunneling events.

    Source

    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.

    Source

    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.

    Source

    Trait implementations

    Availability

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