EVT_CONTEXT_MENU coordinates

When EVT_CONTEXT_MENU origins from right-click, evt.GetPosition() is screen coordinates. When from Context keyboard key, its local cooridinates. Is this a bug or how to distinguish (flag to tell source in evt) ?

>>> wx.version()
'2.8.9.2 (msw-unicode)'

Robert wrote:

When EVT_CONTEXT_MENU origins from right-click, evt.GetPosition() is screen coordinates. When from Context keyboard key, its local cooridinates. Is this a bug or how to distinguish (flag to tell source in evt) ?

>>> wx.version()
'2.8.9.2 (msw-unicode)'

oh, its -1,-1 for key. When passing through to PopupMenu(), it just turns to locals coords.
So one has to check for -1 . hope nobody mouseclicks on screen pos -1,-1 :slight_smile: or is there another flag in the event?

Robert wrote:

Robert wrote:

When EVT_CONTEXT_MENU origins from right-click, evt.GetPosition() is screen coordinates. When from Context keyboard key, its local cooridinates. Is this a bug or how to distinguish (flag to tell source in evt) ?

>>> wx.version()
'2.8.9.2 (msw-unicode)'

oh, its -1,-1 for key. When passing through to PopupMenu(), it just turns to locals coords.
So one has to check for -1 . hope nobody mouseclicks on screen pos -1,-1 :slight_smile: or is there another flag in the event?

If all you need is to show the menu then if you don't pass a position to PopupMenu then it will automatically put it near the mouse cursor, so that will give you one less thing to worry about. If you do need the position for something else then using the -1 check will probably be safe.

···

--
Robin Dunn
Software Craftsman