# Interactive

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/interactivity/struct-interactive/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct Interactive
```

Base class for objects that raise routed events.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L43)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`interactive_parent`](#function-interactive_parent)
- [`DEFAULT_ROUTES`](#assoc_const-default_routes)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`add_handler`](#function-add_handler)
- [`add_handler_with`](#function-add_handler_with)
- [`add_handler_as`](#function-add_handler_as)
- [`add_handler_untyped`](#function-add_handler_untyped)
- [`add_route_handler`](#function-add_route_handler)
- [`remove_handler`](#function-remove_handler)
- [`raise_event`](#function-raise_event)
- [`build_event_route`](#function-build_event_route)
- [`add_disposable_handler`](#function-add_disposable_handler)
- [`add_disposable_handler_with`](#function-add_disposable_handler_with)
- [`get_interactive_parent`](#function-get_interactive_parent)
- [`get_observable`](#function-get_observable)
- [`get_observable_with`](#function-get_observable_with)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L48)

<a id="function-to_ref"></a>

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L48)

<a id="function-interactive_parent"></a>

### interactive_parent

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L48)

<a id="assoc_const-default_routes"></a>

### DEFAULT_ROUTES

```rust
const DEFAULT_ROUTES: RoutingStrategies
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L69)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L72)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L76)

<a id="function-add_handler"></a>

### add_handler

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L91)

<a id="function-add_handler_with"></a>

### add_handler_with

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L105)

<a id="function-add_handler_as"></a>

### add_handler_as

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L126)

<a id="function-add_handler_untyped"></a>

### add_handler_untyped

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L163)

<a id="function-add_route_handler"></a>

### add_route_handler

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L180)

<a id="function-remove_handler"></a>

### remove_handler

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L197)

<a id="function-raise_event"></a>

### raise_event

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

Raises a routed event.

Panics if the args have no routed event.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L223)

<a id="function-build_event_route"></a>

### build_event_route

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive.rs#L234)

<a id="function-add_disposable_handler"></a>

### add_disposable_handler

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive_extensions.rs#L13)

<a id="function-add_disposable_handler_with"></a>

### add_disposable_handler_with

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive_extensions.rs#L24)

<a id="function-get_interactive_parent"></a>

### get_interactive_parent

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive_extensions.rs#L49)

<a id="function-get_observable"></a>

### get_observable

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive_extensions.rs#L57)

<a id="function-get_observable_with"></a>

### get_observable_with

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/interactivity/interactive_extensions.rs#L70)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Interactive>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
