.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.ContextMenuEvent:

==========================================================================================================================================
|phoenix_title|  **wx.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:`wx.Window`.          

Note that if :meth:`wx.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 :ref:`wx.GetMousePosition`. 

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``   event and only if it was not handled but under GTK the context menu event is generated after   ``EVT_RIGHT_DOWN``   event. This is correct in the sense that it ensures that the context menu is shown according to the current platform UI conventions and also means that you must not handle (or call  :meth:`wx.Event.Skip`   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``   event. 

^^ 





.. _ContextMenuEvent-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive a :ref:`wx.ContextMenuEvent` parameter.

Event macros: 

- EVT_CONTEXT_MENU: A right click (or other context menu command depending on platform) has been detected. ^^ 






         



.. seealso:: :ref:`wx.CommandEvent`, :ref:`Events and Event Handling <events and event handling>`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>ContextMenuEvent</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.ContextMenuEvent_inheritance.png" alt="Inheritance diagram of ContextMenuEvent" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.ContextMenuEvent.html" title="wx.ContextMenuEvent" alt="" coords="5,237,173,267"/> <area shape="rect" id="node2" href="wx.CommandEvent.html" title="wx.CommandEvent" alt="" coords="15,160,164,189"/> <area shape="rect" id="node3" href="wx.Event.html" title="wx.Event" alt="" coords="48,83,131,112"/> <area shape="rect" id="node4" href="wx.Object.html" title="wx.Object" alt="" coords="46,5,133,35"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.ContextMenuEvent.__init__`                                            Constructor.
:meth:`~wx.ContextMenuEvent.GetPosition`                                         Returns the position in screen coordinates at which the menu should be shown.
:meth:`~wx.ContextMenuEvent.SetPosition`                                         Sets the position at which the menu should be shown.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.ContextMenuEvent.Position`                                            See :meth:`~wx.ContextMenuEvent.GetPosition` and :meth:`~wx.ContextMenuEvent.SetPosition`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.ContextMenuEvent(CommandEvent)

   **Possible constructors**::

       ContextMenuEvent(type=wxEVT_NULL, id=0, pos=DefaultPosition)
       
   
   This class is used for context menu events, sent to give the
   application a chance to show a context (popup) menu for a Window.



   .. method:: __init__(self, type=wxEVT_NULL, id=0, pos=DefaultPosition)

      Constructor.                  


      :param `type`: 
      :type `type`: wx.EventType
      :param `id`: 
      :type `id`: int
      :param `pos`: 
      :type `pos`: wx.Point







   .. method:: GetPosition(self)

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

      Use :meth:`wx.Window.ScreenToClient`   to convert to client coordinates. 

      You can also omit a position from :meth:`wx.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:`wx.Point`








   .. method:: SetPosition(self, point)

      Sets the position at which the menu should be shown.                  


      :param `point`: 
      :type `point`: wx.Point







   .. attribute:: Position

      See :meth:`~wx.ContextMenuEvent.GetPosition` and :meth:`~wx.ContextMenuEvent.SetPosition`

