# ContextMenu

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

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

```rust
struct ContextMenu
```

A control context menu.

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

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`horizontal_offset_property`](#function-horizontal_offset_property)
- [`vertical_offset_property`](#function-vertical_offset_property)
- [`placement_anchor_property`](#function-placement_anchor_property)
- [`placement_constraint_adjustment_property`](#function-placement_constraint_adjustment_property)
- [`placement_gravity_property`](#function-placement_gravity_property)
- [`placement_property`](#function-placement_property)
- [`placement_rect_property`](#function-placement_rect_property)
- [`window_manager_add_shadow_hint_property`](#function-window_manager_add_shadow_hint_property)
- [`placement_target_property`](#function-placement_target_property)
- [`custom_popup_placement_callback_property`](#function-custom_popup_placement_callback_property)
- [`system_backdrop_property`](#function-system_backdrop_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`system_backdrop`](#function-system_backdrop)
- [`set_system_backdrop`](#function-set_system_backdrop)
- [`horizontal_offset`](#function-horizontal_offset)
- [`set_horizontal_offset`](#function-set_horizontal_offset)
- [`vertical_offset`](#function-vertical_offset)
- [`set_vertical_offset`](#function-set_vertical_offset)
- [`placement_anchor`](#function-placement_anchor)
- [`set_placement_anchor`](#function-set_placement_anchor)
- [`placement_constraint_adjustment`](#function-placement_constraint_adjustment)
- [`set_placement_constraint_adjustment`](#function-set_placement_constraint_adjustment)
- [`placement_gravity`](#function-placement_gravity)
- [`set_placement_gravity`](#function-set_placement_gravity)
- [`placement`](#function-placement)
- [`set_placement`](#function-set_placement)
- [`window_manager_add_shadow_hint`](#function-window_manager_add_shadow_hint)
- [`set_window_manager_add_shadow_hint`](#function-set_window_manager_add_shadow_hint)
- [`placement_rect`](#function-placement_rect)
- [`set_placement_rect`](#function-set_placement_rect)
- [`placement_target`](#function-placement_target)
- [`set_placement_target`](#function-set_placement_target)
- [`custom_popup_placement_callback`](#function-custom_popup_placement_callback)
- [`set_custom_popup_placement_callback`](#function-set_custom_popup_placement_callback)
- [`opening`](#function-opening)
- [`closing`](#function-closing)
- [`open_at`](#function-open_at)
- [`popup_host`](#function-popup_host)
- [`popup_host_changed`](#function-popup_host_changed)
- [`to_popup_host_provider`](#function-to_popup_host_provider)

<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/context_menu.rs#L41)

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

### to_ref

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

Returns a strong reference to this object.

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

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

### horizontal_offset_property

```rust
fn horizontal_offset_property() -> &'static StyledProperty<f64>
```

Defines the `HorizontalOffset` property.

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

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

### vertical_offset_property

```rust
fn vertical_offset_property() -> &'static StyledProperty<f64>
```

Defines the `VerticalOffset` property.

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

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

### placement_anchor_property

```rust
fn placement_anchor_property() -> &'static StyledProperty<PopupAnchor>
```

Defines the `PlacementAnchor` property.

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

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

### placement_constraint_adjustment_property

```rust
fn placement_constraint_adjustment_property() -> &'static StyledProperty<PopupPositionerConstraintAdjustment>
```

Defines the `PlacementConstraintAdjustment` property.

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

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

### placement_gravity_property

```rust
fn placement_gravity_property() -> &'static StyledProperty<PopupGravity>
```

Defines the `PlacementGravity` property.

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

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

### placement_property

```rust
fn placement_property() -> &'static StyledProperty<PlacementMode>
```

Defines the `Placement` property.

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

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

### placement_rect_property

```rust
fn placement_rect_property() -> &'static StyledProperty<Option<Rect>>
```

Defines the `PlacementRect` property.

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

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

### window_manager_add_shadow_hint_property

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

Defines the `WindowManagerAddShadowHint` property.

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

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

### placement_target_property

```rust
fn placement_target_property() -> &'static StyledProperty<Option<ElementRef<Control>>>
```

Defines the `PlacementTarget` property.

The menu does not own its placement target, so the value is an
element reference.

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

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

### custom_popup_placement_callback_property

```rust
fn custom_popup_placement_callback_property() -> &'static StyledProperty<Option<CustomPopupPlacementCallbackValue>>
```

Defines the `CustomPopupPlacementCallback` property.

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

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

### system_backdrop_property

```rust
fn system_backdrop_property() -> &'static StyledProperty<Option<Ref<crate::media::SystemBackdrop>>>
```

Defines the `SystemBackdrop` property: the system backdrop drawn as the
background of the menu (the property of a menu flyout presenter, a FerroUI
addition on the context menu, which is a menu flyout presenter of its own).

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

<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/context_menu.rs#L190)

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

### new

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

Initializes a new instance of the `ContextMenu` class.

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

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

### system_backdrop

```rust
fn system_backdrop(self: &Self) -> Option<Ref<crate::media::SystemBackdrop>>
```

`SystemBackdrop`: the system backdrop drawn as the background of the menu.

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

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

### set_system_backdrop

```rust
fn set_system_backdrop(self: &Self, value: Option<Ref<crate::media::SystemBackdrop>>)
```



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

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

### horizontal_offset

```rust
fn horizontal_offset(self: &Self) -> f64
```

The horizontal offset of the menu in relation to its target; see
`Popup::horizontal_offset`.

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

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

### set_horizontal_offset

```rust
fn set_horizontal_offset(self: &Self, value: f64)
```



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

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

### vertical_offset

```rust
fn vertical_offset(self: &Self) -> f64
```

The vertical offset of the menu in relation to its target; see
`Popup::vertical_offset`.

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

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

### set_vertical_offset

```rust
fn set_vertical_offset(self: &Self, value: f64)
```



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

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

### placement_anchor

```rust
fn placement_anchor(self: &Self) -> PopupAnchor
```

See `Popup::placement_anchor`.

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

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

### set_placement_anchor

```rust
fn set_placement_anchor(self: &Self, value: PopupAnchor)
```



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

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

### placement_constraint_adjustment

```rust
fn placement_constraint_adjustment(self: &Self) -> PopupPositionerConstraintAdjustment
```

See `Popup::placement_constraint_adjustment`.

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

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

### set_placement_constraint_adjustment

```rust
fn set_placement_constraint_adjustment(self: &Self, value: PopupPositionerConstraintAdjustment)
```



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

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

### placement_gravity

```rust
fn placement_gravity(self: &Self) -> PopupGravity
```

See `Popup::placement_gravity`.

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

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

### set_placement_gravity

```rust
fn set_placement_gravity(self: &Self, value: PopupGravity)
```



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

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

### placement

```rust
fn placement(self: &Self) -> PlacementMode
```

See `Popup::placement`.

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

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

### set_placement

```rust
fn set_placement(self: &Self, value: PlacementMode)
```



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

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

### window_manager_add_shadow_hint

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

See `Popup::window_manager_add_shadow_hint`.

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

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

### set_window_manager_add_shadow_hint

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



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

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

### placement_rect

```rust
fn placement_rect(self: &Self) -> Option<Rect>
```

See `Popup::placement_rect`.

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

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

### set_placement_rect

```rust
fn set_placement_rect(self: &Self, value: Option<Rect>)
```



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

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

### placement_target

```rust
fn placement_target(self: &Self) -> Option<Ref<Control>>
```

See `Popup::placement_target`.

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

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

### set_placement_target

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



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

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

### custom_popup_placement_callback

```rust
fn custom_popup_placement_callback(self: &Self) -> Option<CustomPopupPlacementCallback>
```

See `Popup::custom_popup_placement_callback`.

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

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

### set_custom_popup_placement_callback

```rust
fn set_custom_popup_placement_callback(self: &Self, value: Option<CustomPopupPlacementCallback>)
```



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

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

### opening

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

Occurs when the value of the `IsOpen` property is changing from false to true. 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/context_menu.rs#L341)

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

### closing

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

Occurs when the value of the `IsOpen` property is changing from true to false. 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/context_menu.rs#L348)

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

### open_at

```rust
fn open_at(self: &Self, control: Option<&Ref<Control>>)
```

Opens a context menu on the specified control.
## Panics

Panics when `control` is `None` and the menu is attached to no
control, and when `control` is not one of the controls the menu is
attached to.

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

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

### popup_host

```rust
fn popup_host(self: &Self) -> Option<Rc<dyn IPopupHost>>
```

The host of the popup the menu is shown in, while it is open.

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

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

### popup_host_changed

```rust
fn popup_host_changed(self: &Self, handler: impl Fn(Option<&Rc<dyn IPopupHost>>) -> () + 'static) -> Subscription
```

Raised when the popup host changes (the popup host provider contract). 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/context_menu.rs#L456)

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

### to_popup_host_provider

```rust
fn to_popup_host_provider(self: &Self) -> Rc<dyn IPopupHostProvider>
```

The menu as a popup host provider (the diagnostics contract it
implements in the reference).

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`SelectingItemsControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-selectingitemscontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- [`MenuBaseImplExt`](/docs/0.5.0/api/ferroui-controls/trait-menubaseimplext/)
- [`ItemsControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-itemscontrolimplext/)
- `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<ContextMenu>`](/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/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ItemsControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-itemscontrolimpl/)
- [`SelectingItemsControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-selectingitemscontrolimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`MenuBaseImpl`](/docs/0.5.0/api/ferroui-controls/trait-menubaseimpl/)
- [`ISetterValue`](/docs/0.5.0/api/ferroui-base/styling/trait-isettervalue/)

## Availability

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