# MenuItemAutomationPeer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/automation/peers/struct-menuitemautomationpeer/

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

```rust
struct MenuItemAutomationPeer
```

An automation peer which represents a [`MenuItem`](/docs/0.5.0/api/ferroui-controls/struct-menuitem/).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L24)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`owner`](#function-owner)
- [`expand_collapse_state`](#function-expand_collapse_state)
- [`shows_menu`](#function-shows_menu)
- [`invoke`](#function-invoke)
- [`expand`](#function-expand)
- [`collapse`](#function-collapse)

<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/automation/peers/menu_item_automation_peer.rs#L28)

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

### to_ref

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

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L28)

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

### construct

```rust
fn construct(owner: &MenuItem) -> Self
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L172)

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

### new

```rust
fn new(owner: &MenuItem) -> Ref<Self>
```

Initializes a new peer of `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L177)

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

### owner

```rust
fn owner(self: &Self) -> Ref<MenuItem>
```

Gets the owning menu item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L182)

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

### expand_collapse_state

```rust
fn expand_collapse_state(self: &Self) -> ExpandCollapseState
```

Gets the state, expanded or collapsed, of the submenu of the item
(the expand/collapse provider contract).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L198)

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

### shows_menu

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

Gets a value indicating whether expanding the item shows a menu
(the expand/collapse provider contract).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L212)

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

### invoke

```rust
fn invoke(self: &Self) -> Result<(), ElementNotEnabledError>
```

Sends a request to activate the menu item (the invoke provider
contract).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L218)

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

### expand

```rust
fn expand(self: &Self) -> Result<(), AutomationError>
```

Opens the submenu of the item (the expand/collapse provider
contract).
## Errors

`AutomationError::ElementNotEnabled` if the item is not enabled,
`AutomationError::InvalidOperation` if it has no submenu.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L247)

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

### collapse

```rust
fn collapse(self: &Self) -> Result<(), AutomationError>
```

Closes the submenu of the item (the expand/collapse provider
contract).
## Errors

`AutomationError::ElementNotEnabled` if the item is not enabled,
`AutomationError::InvalidOperation` if it has no submenu.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/automation/peers/menu_item_automation_peer.rs#L264)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AutomationPeerImplExt`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-automationpeerimplext/)
- [`ControlAutomationPeerImplExt`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-controlautomationpeerimplext/)
- `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<MenuItemAutomationPeer>`](/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/)
- [`ControlAutomationPeerImpl`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-controlautomationpeerimpl/)
- [`AutomationPeerImpl`](/docs/0.5.0/api/ferroui-controls/automation/peers/trait-automationpeerimpl/)

## Availability

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