Skip to content

Commit 5afb0d6

Browse files
committed
exposed the mouse button event "clicks" property
1 parent 75d893c commit 5afb0d6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docs/reST/ref/event.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ specific attributes.
7272
KEYDOWN key, mod, unicode, scancode
7373
KEYUP key, mod, unicode, scancode
7474
MOUSEMOTION pos, rel, buttons, touch
75-
MOUSEBUTTONUP pos, button, touch
76-
MOUSEBUTTONDOWN pos, button, touch
75+
MOUSEBUTTONUP pos, button, touch, clicks
76+
MOUSEBUTTONDOWN pos, button, touch, clicks
7777
JOYAXISMOTION joy (deprecated), instance_id, axis, value
7878
JOYBALLMOTION joy (deprecated), instance_id, ball, rel
7979
JOYHATMOTION joy (deprecated), instance_id, hat, value
@@ -87,6 +87,12 @@ specific attributes.
8787

8888
.. versionchangedold:: 2.0.1 The ``unicode`` attribute was added to ``KEYUP`` event.
8989

90+
.. versionchangedold:: 2.5.7 The ``clicks`` attribute was added to ``MOUSEBUTTONDOWN`` and ``MOUSEBUTTONUP`` events.
91+
92+
The ``clicks`` attribute of the ``MOUSEBUTTONDOWN`` and ``MOUSEBUTTONUP`` events indicate the number of clicks occurring
93+
in rapid succession, e.g. ``1`` for single-click, ``2`` for double-click, etc. Note that double, triple, or more clicks
94+
will still fire mouse events for each individual click, with a progressively increasing ``clicks`` attribute.
95+
9096
Note that ``ACTIVEEVENT``, ``VIDEORESIZE`` and ``VIDEOEXPOSE`` are considered
9197
as "legacy" events, the use of pygame2 ``WINDOWEVENT`` API is recommended over
9298
the use of this older API.

src_c/event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ dict_from_event(SDL_Event *event)
12111211
(int)event->button.y);
12121212
_pg_insobj(dict, "pos", obj);
12131213
_pg_insobj(dict, "button", PyLong_FromLong(event->button.button));
1214+
_pg_insobj(dict, "clicks", PyLong_FromLong(event->button.clicks));
12141215
_pg_insobj(
12151216
dict, "touch",
12161217
PyBool_FromLong((event->button.which == SDL_TOUCH_MOUSEID)));

0 commit comments

Comments
 (0)