# NativeMenu

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

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

```rust
struct NativeMenu
```

A menu that is shown by the platform: the menu of a window or of the
application, the menu of a tray icon or of the dock.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`parent_property`](#function-parent_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`items`](#function-items)
- [`needs_update`](#function-needs_update)
- [`opening`](#function-opening)
- [`closed`](#function-closed)
- [`parent`](#function-parent)
- [`to_exporter_events_bridge`](#function-to_exporter_events_bridge)
- [`add`](#function-add)
- [`iter`](#function-iter)
- [`is_native_menu_exported_property`](#function-is_native_menu_exported_property)
- [`menu_property`](#function-menu_property)
- [`get_is_native_menu_exported`](#function-get_is_native_menu_exported)
- [`set_menu`](#function-set_menu)
- [`get_menu`](#function-get_menu)

<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/native_menu.rs#L28)

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

### to_ref

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

Returns a strong reference to this object.

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

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

### parent_property

```rust
fn parent_property() -> &'static DirectProperty<NativeMenu, Option<Ref<NativeMenuItem>>>
```

Defines the `Parent` property.

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

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

### construct

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

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

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

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

### new

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



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

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

### items

```rust
fn items(self: &Self) -> FerroList<Ref<NativeMenuItemBase>>
```

The items of the menu.

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

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

### needs_update

```rust
fn needs_update(self: &Self, handler: impl Fn(&NativeMenu) -> () + 'static) -> Subscription
```

Raised when the menu requests an update.

Use this event to add, remove or modify menu items before a menu is
shown or a hotkey is pressed.

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the menu.

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

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

### opening

```rust
fn opening(self: &Self, handler: impl Fn(&NativeMenu) -> () + 'static) -> Subscription
```

Raised before the menu is opened.

Do not update the menu in this event; use
`needs_update`.

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the menu.

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

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

### closed

```rust
fn closed(self: &Self, handler: impl Fn(&NativeMenu) -> () + 'static) -> Subscription
```

Raised after the menu is closed.

Do not update the menu in this event; use
`needs_update`.

Dropping the returned guard removes the handler; `Subscription::detach` keeps it for the
life of the menu.

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

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

### parent

```rust
fn parent(self: &Self) -> Option<Ref<NativeMenuItem>>
```

The item the menu is the submenu of.

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

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

### to_exporter_events_bridge

```rust
fn to_exporter_events_bridge(self: &Self) -> Rc<dyn INativeMenuExporterEventsImplBridge>
```

The menu viewed as the contract through which the platform exporter
of the menu raises its events.

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

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

### add

```rust
fn add(self: &Self, item: impl IntoRef<NativeMenuItemBase>)
```

Adds an item to the menu.

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

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

### iter

```rust
fn iter(self: &Self) -> std::vec::IntoIter<Ref<NativeMenuItemBase>>
```

Enumerates the items of the menu.

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

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

### is_native_menu_exported_property

```rust
fn is_native_menu_exported_property() -> &'static AttachedProperty<bool>
```

Defines the `IsNativeMenuExported` attached property.

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

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

### menu_property

```rust
fn menu_property() -> &'static AttachedProperty<Option<Ref<NativeMenu>>>
```

Defines the `Menu` attached property.

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

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

### get_is_native_menu_exported

```rust
fn get_is_native_menu_exported(tl: &TopLevel) -> bool
```

Whether the native menu of the top-level is exported to the
platform.

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

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

### set_menu

```rust
fn set_menu(o: &FerroObject, menu: Option<Ref<NativeMenu>>)
```

Sets the native menu of an object: a top-level, the application or
an object that provides a native menu exporter.

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

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

### get_menu

```rust
fn get_menu(o: &FerroObject) -> Option<Ref<NativeMenu>>
```

Gets the native menu of an object.

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

## 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<NativeMenu>`](/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/)
- `IntoIterator`

## Availability

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