# StateTriggerBase

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/visual_state/struct-statetriggerbase/

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

```rust
struct StateTriggerBase
```

The base class of the triggers of a `VisualState`: while a trigger of a
state is active, the state is a candidate to be the current state of its group
(docs/porting/winui-calculator-gaps.md, section 5.7).

**The extension point of custom triggers.** A trigger of an application derives from this
class and calls `set_active` when its condition changes (WinUI's protected
`SetActive`; it is public in Rust, which has no protected members, and is meant for the
derived trigger only):

```ignore
#[repr(C)]
pub struct ControlSizeTrigger { base: StateTriggerBase, /* ... */ }
ferro_class!(ControlSizeTrigger: StateTriggerBase);
// ... on a size change of the source:
trigger.set_active(size.width >= trigger.min_width());
```

Among the states of a group whose triggers are active, a [`StateTrigger`](/docs/0.5.0/api/ferroui-controls/visual_state/struct-statetrigger/) or a custom trigger
wins over an [`AdaptiveTrigger`](/docs/0.5.0/api/ferroui-controls/visual_state/struct-adaptivetrigger/); among adaptive triggers the larger `MinWindowWidth` wins,
then the larger `MinWindowHeight`; then the first in the order of the source.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/visual_state/state_trigger_base.rs#L36)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`set_active`](#function-set_active)

<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.Controls/visual_state/state_trigger_base.rs#L43)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/visual_state/state_trigger_base.rs#L43)

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

### construct

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

Creates the class data of a derived trigger (WinUI's protected constructor); the trigger
is not active.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/visual_state/state_trigger_base.rs#L50)

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

### set_active

```rust
fn set_active(self: &Self, value: bool)
```

Sets whether the trigger is active (WinUI's protected `SetActive`). The group of the
trigger selects its state again when the value changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/visual_state/state_trigger_base.rs#L56)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `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`
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<StateTriggerBase>`](/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/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)

## Availability

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