.. include:: headings.inc .. _ContextMenuEvent: ========================================================================================================================================== |phoenix_title| **ContextMenuEvent** ========================================================================================================================================== This class is used for context menu events, sent to give the application a chance to show a context (popup) menu for a :ref:`Window`. Note that if :meth:`ContextMenuEvent.GetPosition` returns DefaultPosition, this means that the event originated from a keyboard context button event, and you should compute a suitable position yourself, for example by calling :func:`GetMousePosition`. When a keyboard context menu button is pressed on Windows, a right-click event with default position is sent first, and if this event is not processed, the context menu event is sent. So if you process mouse events and you find your context menu event handler is not being called, you could call :meth:`Event.Skip` for mouse right-down events. .. _ContextMenuEvent-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`ContextMenuEvent` parameter. - EVT_CONTEXT_MENU: A right click (or other context menu command depending on platform) has been detected. .. seealso:: :ref:`CommandEvent`, :ref:`Events and Event Handling ` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **ContextMenuEvent** .. raw:: html

Inheritance diagram of ContextMenuEvent

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~ContextMenuEvent.__init__` Constructor. :meth:`~ContextMenuEvent.GetPosition` Returns the position in screen coordinates at which the menu should be shown. :meth:`~ContextMenuEvent.SetPosition` Sets the position at which the menu should be shown. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~ContextMenuEvent.Position` See :meth:`~ContextMenuEvent.GetPosition` and :meth:`~ContextMenuEvent.SetPosition` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: ContextMenuEvent(CommandEvent) This class is used for context menu events, sent to give the application a chance to show a context (popup) menu for a Window. **Possible constructors**:: ContextMenuEvent(type=wxEVT_NULL, id=0, pos=DefaultPosition) .. method:: __init__(self, type=wxEVT_NULL, id=0, pos=DefaultPosition) Constructor. :param `type`: :type `type`: EventType :param `id`: :type `id`: int :param `pos`: :type `pos`: Point .. method:: GetPosition(self) Returns the position in screen coordinates at which the menu should be shown. Use :meth:`Window.ScreenToClient` to convert to client coordinates. You can also omit a position from :meth:`Window.PopupMenu` 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 DefaultPosition. :rtype: :ref:`Point` .. method:: SetPosition(self, point) Sets the position at which the menu should be shown. :param `point`: :type `point`: Point .. attribute:: Position See :meth:`~ContextMenuEvent.GetPosition` and :meth:`~ContextMenuEvent.SetPosition`