# RoutedEvent

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

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

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

## Members

- [`new_untyped`](#function-new_untyped)
- [`register`](#function-register)
- [`register_with_owner`](#function-register_with_owner)
- [`as_routed_event`](#function-as_routed_event)
- [`event_args_type`](#function-event_args_type)
- [`event_args_type_name`](#function-event_args_type_name)
- [`event_args_is`](#function-event_args_is)
- [`name`](#function-name)
- [`owner_type`](#function-owner_type)
- [`routing_strategies`](#function-routing_strategies)
- [`has_raised_subscriptions`](#function-has_raised_subscriptions)
- [`has_instance_handlers`](#function-has_instance_handlers)
- [`raised`](#function-raised)
- [`route_finished`](#function-route_finished)
- [`add_class_handler_untyped`](#function-add_class_handler_untyped)
- [`new`](#function-new)
- [`add_class_handler`](#function-add_class_handler)
- [`add_class_handler_with`](#function-add_class_handler_with)

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

### new_untyped

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

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

### register

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

Registers a routed event owned by class `TOwner`.

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

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

### register_with_owner

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

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

### as_routed_event

```rust
fn as_routed_event(self: &Self) -> RoutedEvent
```

The untyped handle of this routed event.

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

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

### event_args_type

```rust
fn event_args_type(self: &Self) -> TypeId
```

The type of the event's args.

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

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

### event_args_type_name

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

The Rust type name of the event's args.

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

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

### event_args_is

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

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

### name

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

The name of the event.

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

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

### owner_type

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

The class that registered the event.

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

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

### routing_strategies

```rust
fn routing_strategies(self: &Self) -> RoutingStrategies
```

How the event travels through the tree.

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

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

### has_raised_subscriptions

```rust
fn has_raised_subscriptions(self: &Self) -> bool
```

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

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

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

### has_instance_handlers

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

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

### raised

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

Notifications of the event being raised on any element.

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

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

### route_finished

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

Notifications of the event having finished one of its routes.

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

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

### add_class_handler_untyped

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

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

### new

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

Creates a routed event without registering it.

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

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

### add_class_handler

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

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

### add_class_handler_with

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-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`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

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