# Button

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

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

```rust
struct Button
```

A standard button control.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`on_click`](#function-on_click)
- [`open_flyout`](#function-open_flyout)
- [`close_flyout`](#function-close_flyout)
- [`on_flyout_opened`](#function-on_flyout_opened)
- [`on_flyout_closed`](#function-on_flyout_closed)
- [`PSEUDO_CLASSES`](#assoc_const-pseudo_classes)
- [`click_mode_property`](#function-click_mode_property)
- [`command_property`](#function-command_property)
- [`hot_key_property`](#function-hot_key_property)
- [`command_parameter_property`](#function-command_parameter_property)
- [`is_default_property`](#function-is_default_property)
- [`is_cancel_property`](#function-is_cancel_property)
- [`click_event`](#function-click_event)
- [`is_pressed_property`](#function-is_pressed_property)
- [`flyout_property`](#function-flyout_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`click`](#function-click)
- [`click_mode`](#function-click_mode)
- [`set_click_mode`](#function-set_click_mode)
- [`command`](#function-command)
- [`set_command`](#function-set_command)
- [`hot_key`](#function-hot_key)
- [`set_hot_key`](#function-set_hot_key)
- [`command_parameter`](#function-command_parameter)
- [`set_command_parameter`](#function-set_command_parameter)
- [`is_default`](#function-is_default)
- [`set_is_default`](#function-set_is_default)
- [`is_cancel`](#function-is_cancel)
- [`set_is_cancel`](#function-set_is_cancel)
- [`is_pressed`](#function-is_pressed)
- [`flyout`](#function-flyout)
- [`set_flyout`](#function-set_flyout)

<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/button.rs#L63)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### on_click

```rust
fn on_click(self: &Self)
```

Invokes the `Click` event.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### open_flyout

```rust
fn open_flyout(self: &Self)
```

Opens the button's flyout.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### close_flyout

```rust
fn close_flyout(self: &Self)
```

Closes the button's flyout.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### on_flyout_opened

```rust
fn on_flyout_opened(self: &Self)
```

Invoked when the button's flyout is opened.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### on_flyout_closed

```rust
fn on_flyout_closed(self: &Self)
```

Invoked when the button's flyout is closed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L63)

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

### PSEUDO_CLASSES

```rust
const PSEUDO_CLASSES: PseudoClassesAttribute
```

The pseudoclasses set by the class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L455)

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

### click_mode_property

```rust
fn click_mode_property() -> &'static StyledProperty<ClickMode>
```

Defines the `ClickMode` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### command_property

```rust
fn command_property() -> &'static StyledProperty<Option<Rc<dyn ICommand>>>
```

Defines the `Command` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### hot_key_property

```rust
fn hot_key_property() -> &'static StyledProperty<Option<KeyGesture>>
```

Defines the `HotKey` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### command_parameter_property

```rust
fn command_parameter_property() -> &'static StyledProperty<Option<BoxedValue>>
```

Defines the `CommandParameter` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### is_default_property

```rust
fn is_default_property() -> &'static StyledProperty<bool>
```

Defines the `IsDefault` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### is_cancel_property

```rust
fn is_cancel_property() -> &'static StyledProperty<bool>
```

Defines the `IsCancel` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L458)

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

### click_event

```rust
fn click_event() -> &'static RoutedEvent<RoutedEventArgs>
```

Defines the `Click` event.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L509)

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

### is_pressed_property

```rust
fn is_pressed_property() -> &'static DirectProperty<Button, bool>
```

Defines the `IsPressed` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L516)

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

### flyout_property

```rust
fn flyout_property() -> &'static StyledProperty<Option<Ref<FlyoutBase>>>
```

Defines the `Flyout` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L523)

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

### construct

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L540)

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

### new

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

Creates a button.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L556)

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

### click

```rust
fn click(self: &Self, handler: impl Fn(&Interactive, &RoutedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
```

Raised when the user clicks the button.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L561)

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

### click_mode

```rust
fn click_mode(self: &Self) -> ClickMode
```

A value indicating how the button should react to clicks.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L566)

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

### set_click_mode

```rust
fn set_click_mode(self: &Self, value: ClickMode)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L570)

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

### command

```rust
fn command(self: &Self) -> Option<Rc<dyn ICommand>>
```

A command to be invoked when the button is clicked.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L575)

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

### set_command

```rust
fn set_command(self: &Self, value: Option<Rc<dyn ICommand>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L579)

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

### hot_key

```rust
fn hot_key(self: &Self) -> Option<KeyGesture>
```

A key gesture associated with this control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L584)

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

### set_hot_key

```rust
fn set_hot_key(self: &Self, value: Option<KeyGesture>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L588)

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

### command_parameter

```rust
fn command_parameter(self: &Self) -> Option<BoxedValue>
```

A parameter to be passed to the `Command`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L593)

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

### set_command_parameter

```rust
fn set_command_parameter(self: &Self, value: Option<BoxedValue>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L597)

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

### is_default

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

A value indicating whether the button is the default button for the
root it is attached to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L603)

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

### set_is_default

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L607)

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

### is_cancel

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

A value indicating whether the button is the Cancel button for the
root it is attached to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L613)

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

### set_is_cancel

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L617)

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

### is_pressed

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

A value indicating whether the button is currently pressed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L623)

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

### flyout

```rust
fn flyout(self: &Self) -> Option<Ref<FlyoutBase>>
```

The flyout that should be shown with this button.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L632)

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

### set_flyout

```rust
fn set_flyout(self: &Self, value: impl Into<Nullable<FlyoutBase>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/button.rs#L636)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ContentControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- [`ButtonImplExt`](/docs/0.5.0/api/ferroui-controls/trait-buttonimplext/)
- `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`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`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/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<Button>`](/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/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`ContentControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`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/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ButtonImpl`](/docs/0.5.0/api/ferroui-controls/trait-buttonimpl/)

## Availability

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