wxContextMenuEvent(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– wxContextMenuEvent πŸ’–

ok so bestie, this is the Erlang module page for wxContextMenuEvent β€” yes it's giving very "wx" but stay with me, it's actually so good.


✨ NAME ✨

wxContextMenuEvent β€” this class is literally for context menu events πŸŽ€ it gets sent so your application gets a chance to pop up a context (popup) menu for a wxWindow. that's the whole job. iconic of it.


🌸 DESCRIPTION 🌸

okay important heads-up first, no cap: if getPosition/1 hands you back wxDefaultPosition, that means the event came from a keyboard context button event πŸ’… so you gotta compute a suitable position yourself β€” like, for example by calling wx_misc:getMousePosition/0. do not just vibe with the default, it will not work.

notice that the exact sequence of mouse events is different across the platforms. for example: under MSW the context menu event is generated after EVT_RIGHT_UP, and only if it was not handled β€” but under GTK the context menu event is generated after EVT_RIGHT_DOWN. and this is actually correct bestie, in the sense that it ensures the context menu is shown according to the current platform UI conventions 🫢

but 😭 it also means: you must not handle (or call wxEvent:skip/2 in your handler if you do have one) neither right mouse down nor right mouse up event, if you plan on handling EVT_CONTEXT_MENU. periodt. don't do it.

See:

  • wxCommandEvent
  • Overview events

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

  • wxCommandEvent
  • wxEvent

wxWidgets docs: wxContextMenuEvent πŸ¦‹

πŸŽ€ Events πŸŽ€

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


⭐ DATA TYPES ⭐

  • wxContextMenu() :: #wxContextMenu{}.
  • wxContextMenuEvent() :: wx:wx_object().
  • wxContextMenuEventType() :: context_menu.

πŸ’… FUNCTIONS πŸ’…

  • getPosition(This) -> {X :: integer(), Y :: integer()} when This :: wxContextMenuEvent().

Returns the position in screen coordinates at which the menu should be shown.

Use wxWindow:screenToClient/2 to convert to client coordinates.

You can also omit a position from wxWindow:popupMenu/4 in order to use the current mouse pointer position. πŸ–±οΈβœ¨

If the event originated from a keyboard event, the value returned from this function will be wxDefaultPosition.

  • setPosition(This, Point) -> ok when This :: wxContextMenuEvent(), Point :: {X :: integer(), Y :: integer()}.

Sets the position at which the menu should be shown. slay. πŸ’…


πŸ’€ reminder bestie: wxDefaultPosition from getPosition/1 = keyboard origin = compute it yourself. and do NOT touch right down / right up if EVT_CONTEXT_MENU is your moment. iykyk.

and that's the whole page, babe 🌈 brought to you with love from Ericsson AB, wx 2.6, and the letter "w" β€” mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from