diff --git a/docs/source/enable/mouse_events.rst b/docs/source/enable/mouse_events.rst new file mode 100644 index 000000000..bea8eebfa --- /dev/null +++ b/docs/source/enable/mouse_events.rst @@ -0,0 +1,53 @@ +Enable Mouse Events +=================== + +Enable mouse events are represented by the :class:`~.MouseEvent` type and their +event names (which are the suffixes used by +:py:meth:`enable.interactor.Interactor.dispatch`) can be divided into two +groups: mouse clicks and mouse movements. The mouse click events have names +ending in ``_down``, ``_up``, or ``_dclick`` and names beginning with ``left``, +``right``, or ``middle``. This means that Enable only supports three mouse +buttons (plus wheel events). + +Event types +----------- + +\*_down +~~~~~~~ +A mouse button was pressed. Dispatched as ``left_down``, ``right_down``, or +``middle_down``. + +\*_up +~~~~~ +A mouse button was released. Dispatched as ``left_up``, ``right_up``, or +``middle_up``. + +\*_dclick +~~~~~~~~~ +A mouse button was double-clicked. Dispatched as ``left_dclick``, +``right_dclick``, or ``middle_dclick``. + +move +~~~~ +The mouse moved within a component. + +enter +~~~~~ +The mouse moved into a component's bounds. + +leave +~~~~~ +The mouse moved out of a component's bounds. + +wheel +~~~~~ +The mouse wheel moved. + +MouseEvent +---------- +Below is a listing of the traits on a `MouseEvent` instance. + +.. autoclass:: enable.events.MouseEvent + :members: alt_down, control_down, shift_down, left_down, middle_down, right_down, mouse_wheel, mouse_wheel_axis, mouse_wheel_delta + :noindex: + diff --git a/docs/source/index.rst b/docs/source/index.rst index f379e14da..a84c6785f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -17,6 +17,7 @@ Enable Documentation enable/abstract_window enable/constraints_layout enable/key_events + enable/mouse_events enable/basic_tools enable/drag_and_drop enable/undo_redo diff --git a/enable/events.py b/enable/events.py index 2cf7971ac..b67e54f95 100644 --- a/enable/events.py +++ b/enable/events.py @@ -130,14 +130,25 @@ def __repr__(self): class MouseEvent(BasicEvent): + """ A mouse event. + """ + #: If True, the ALT key is pressed on the keyboard alt_down = ReadOnly + #: If True, the CTRL key is pressed on the keyboard control_down = ReadOnly + #: If True, a SHIFT key is pressed on the keyboard shift_down = ReadOnly + #: If True, the left button is pressed on the mouse left_down = ReadOnly + #: If True, the middle button is pressed on the mouse middle_down = ReadOnly + #: If True, the right button is pressed on the mouse right_down = ReadOnly + #: If a wheel event, holds number of units moved by the wheel mouse_wheel = ReadOnly + #: If a wheel event, contains either "horizontal" or "vertical" mouse_wheel_axis = ReadOnly + #: If a wheel event, contains a 2D movement vector as a tuple mouse_wheel_delta = ReadOnly