From 33a564152ffede4b8ed8b14ec8c79eb55bcee000 Mon Sep 17 00:00:00 2001 From: John Wiggins Date: Mon, 15 Mar 2021 11:52:45 +0100 Subject: [PATCH 1/2] Add documentation for mouse events --- docs/source/enable/mouse_events.rst | 52 +++++++++++++++++++++++++++++ docs/source/index.rst | 1 + enable/events.py | 11 ++++++ 3 files changed, 64 insertions(+) create mode 100644 docs/source/enable/mouse_events.rst diff --git a/docs/source/enable/mouse_events.rst b/docs/source/enable/mouse_events.rst new file mode 100644 index 000000000..019d0e0ca --- /dev/null +++ b/docs/source/enable/mouse_events.rst @@ -0,0 +1,52 @@ +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:`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 25c4c91d0..b521cbed6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -16,6 +16,7 @@ Enable Documentation enable/overview.rst enable/constraints_layout.rst enable/key_events.rst + enable/mouse_events.rst enable/basic_tools.rst enable/drag_and_drop.rst enable/undo_redo.rst 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 From 653687c5320f86fbffed02318427f7d0c13b6385 Mon Sep 17 00:00:00 2001 From: John Wiggins Date: Mon, 15 Mar 2021 14:19:58 +0100 Subject: [PATCH 2/2] PR feedback --- docs/source/enable/mouse_events.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/source/enable/mouse_events.rst b/docs/source/enable/mouse_events.rst index 019d0e0ca..bea8eebfa 100644 --- a/docs/source/enable/mouse_events.rst +++ b/docs/source/enable/mouse_events.rst @@ -1,12 +1,13 @@ 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:`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). +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 -----------