# `wxMenuEvent`
[🔗](https://github.com/erlang/otp/blob/master/lib/wx/src/gen/wxMenuEvent.erl#L58)

This class is used for a variety of menu-related events.

Note that these do not include menu command events, which are handled using `m:wxCommandEvent`
objects.

Events of this class are generated by both menus that are part of a `m:wxMenuBar`,
attached to `m:wxFrame`, and popup menus shown by `wxWindow:popupMenu/4`. They are sent to the following objects
until one of them handles the event: `-# The menu object itself, as returned by GetMenu(), if any. -# The wxMenuBar to which
this menu is attached, if any. -# The window associated with the menu, e.g. the one
calling PopupMenu() for the popup menus. -# The top level parent of that window if it's
different from the window itself. `
This is similar to command events generated by the menu items, but, unlike them, `m:wxMenuEvent`
are only sent to the window itself and its top level parent but not any intermediate
windows in the hierarchy.

The default handler for `wxEVT_MENU_HIGHLIGHT` in `m:wxFrame` displays help text in the
status bar, see `wxFrame:setStatusBarPane/2`.

See:
* `m:wxCommandEvent`

* [Overview events](https://docs.wxwidgets.org/3.2/overview_events.html#overview_events)

This class is derived, and can use functions, from:

* `m:wxEvent`

wxWidgets docs: [wxMenuEvent](https://docs.wxwidgets.org/3.2/classwx_menu_event.html)

## Events

Use `wxEvtHandler:connect/3` with `wxMenuEventType` to subscribe to events of this type.

# `wxMenu`

```elixir
-type wxMenu() ::
          #wxMenu{type :: wxMenuEvent:wxMenuEventType(), menuId :: integer(), menu :: wxMenu:wxMenu()}.
```

# `wxMenuEvent`

```elixir
-type wxMenuEvent() :: wx:wx_object().
```

# `wxMenuEventType`

```elixir
-type wxMenuEventType() :: menu_open | menu_close | menu_highlight.
```

# `getMenu`

```elixir
-spec getMenu(This) -> wxMenu:wxMenu() when This :: wxMenuEvent().
```

Returns the menu which is being opened or closed, or the menu containing the highlighted
item.

Note that the returned value can be NULL if the menu being opened doesn't have a
corresponding `m:wxMenu`, e.g. this happens when opening the system menu in wxMSW port.

Remark: Since 3.1.3 this function can be used with `OPEN`, `CLOSE` and `HIGHLIGHT`
events. Before 3.1.3, this method can only be used with the `OPEN` and `CLOSE` events.

# `getMenuId`

```elixir
-spec getMenuId(This) -> integer() when This :: wxMenuEvent().
```

Returns the menu identifier associated with the event.

This method should be only used with the `HIGHLIGHT` events.

# `isPopup`

```elixir
-spec isPopup(This) -> boolean() when This :: wxMenuEvent().
```

Returns true if the menu which is being opened or closed is a popup menu, false if it is
a normal one.

This method should only be used with the `OPEN` and `CLOSE` events.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
