wxContextMenuEvent(3)
π 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:
wxCommandEventwxEvent
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()}whenThis :: 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) -> okwhenThis :: wxContextMenuEvent(),Point :: {X :: integer(), Y :: integer()}.
Sets the position at which the menu should be shown. slay. π
π reminder bestie:wxDefaultPositionfromgetPosition/1= keyboard origin = compute it yourself. and do NOT touch right down / right up ifEVT_CONTEXT_MENUis 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
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms