Skip to content

Commit 14cfa32

Browse files
authored
bpo-39273: Expose BUTTON5_* constants in the curses module if available (GH-17996)
1 parent a330365 commit 14cfa32

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

Doc/library/curses.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,15 @@ The module :mod:`curses` defines the following functions:
220220
multiple devices, and *x*, *y*, *z* are the event's coordinates. (*z* is
221221
currently unused.) *bstate* is an integer value whose bits will be set to
222222
indicate the type of event, and will be the bitwise OR of one or more of the
223-
following constants, where *n* is the button number from 1 to 4:
223+
following constants, where *n* is the button number from 1 to 5:
224224
:const:`BUTTONn_PRESSED`, :const:`BUTTONn_RELEASED`, :const:`BUTTONn_CLICKED`,
225225
:const:`BUTTONn_DOUBLE_CLICKED`, :const:`BUTTONn_TRIPLE_CLICKED`,
226226
:const:`BUTTON_SHIFT`, :const:`BUTTON_CTRL`, :const:`BUTTON_ALT`.
227227

228+
.. versionchanged:: 3.10
229+
The ``BUTTON5_*`` constants are now exposed if they are provided by the
230+
underlying curses library.
231+
228232

229233
.. function:: getsyx()
230234

Doc/whatsnew/3.10.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ by :func:`curses.color_content`, :func:`curses.init_color`,
242242
support is provided by the underlying ncurses library.
243243
(Contributed by Jeffrey Kintscher and Hans Petter Jansson in :issue:`36982`.)
244244

245+
The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if
246+
they are provided by the underlying curses library.
247+
(Contributed by Zackery Spytz in :issue:`39273`.)
248+
245249
distutils
246250
---------
247251

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The ``BUTTON5_*`` constants are now exposed in the :mod:`curses` module if
2+
available.

Modules/_cursesmodule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4870,6 +4870,14 @@ PyInit__curses(void)
48704870
SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED);
48714871
SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED);
48724872

4873+
#if NCURSES_MOUSE_VERSION > 1
4874+
SetDictInt("BUTTON5_PRESSED", BUTTON5_PRESSED);
4875+
SetDictInt("BUTTON5_RELEASED", BUTTON5_RELEASED);
4876+
SetDictInt("BUTTON5_CLICKED", BUTTON5_CLICKED);
4877+
SetDictInt("BUTTON5_DOUBLE_CLICKED", BUTTON5_DOUBLE_CLICKED);
4878+
SetDictInt("BUTTON5_TRIPLE_CLICKED", BUTTON5_TRIPLE_CLICKED);
4879+
#endif
4880+
48734881
SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT);
48744882
SetDictInt("BUTTON_CTRL", BUTTON_CTRL);
48754883
SetDictInt("BUTTON_ALT", BUTTON_ALT);

0 commit comments

Comments
 (0)