Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curses constant names for mouse wheel movements? #18

Open
pjfarleyiii opened this issue Mar 7, 2021 · 0 comments
Open

curses constant names for mouse wheel movements? #18

pjfarleyiii opened this issue Mar 7, 2021 · 0 comments
Labels
question Further information is requested

Comments

@pjfarleyiii
Copy link

pjfarleyiii commented Mar 7, 2021

I have a python curses project trying to detect mouse wheel movements, and I understand that mouse wheel events by convention are reported as BUTTON4 and BUTTON5 events.

I am running on a Win10 system with python 3.8.7 and windows-curses 2.2.0, which I am given to understand uses the gohlke PDCurses wheels for the underlying curses implementation.

I can display the values of all of the BUTTON1 to BUTTON4 event constants but python 3.8.7 barfs if I try to use any BUTTON5 event names. It also does not recognize the BUTTONn_RESERVED_EVENT names for buttons 1-4.

print(       "B1={:08x},{:08x},{:08x},{:08x},{:08x}\n".format(
                    curses.BUTTON1_RELEASED, curses.BUTTON1_PRESSED, curses.BUTTON1_CLICKED, 
                    curses.BUTTON1_DOUBLE_CLICKED, curses.BUTTON1_TRIPLE_CLICKED) + \
                "B2={:08x},{:08x},{:08x},{:08x},{:08x}\n".format(
                    curses.BUTTON2_RELEASED, curses.BUTTON2_PRESSED, curses.BUTTON2_CLICKED, 
                    curses.BUTTON2_DOUBLE_CLICKED, curses.BUTTON2_TRIPLE_CLICKED) + \
                "B3={:08x},{:08x},{:08x},{:08x},{:08x}\n".format(
                    curses.BUTTON3_RELEASED, curses.BUTTON3_PRESSED, curses.BUTTON3_CLICKED, 
                    curses.BUTTON3_DOUBLE_CLICKED, curses.BUTTON3_TRIPLE_CLICKED) + \
                "B4={:08x},{:08x},{:08x},{:08x},{:08x}\n".format(
                    curses.BUTTON4_RELEASED, curses.BUTTON4_PRESSED, curses.BUTTON4_CLICKED, 
                    curses.BUTTON4_DOUBLE_CLICKED, curses.BUTTON4_TRIPLE_CLICKED) + \
                "S/C/A={:08x},{:08x},{:08x}".format(
                    curses.BUTTON_SHIFT, curses.BUTTON_CTRL, curses.BUTTON_ALT))

yields this output:

B1=00000001,00000002,00000004,00000008,00000010
B2=00000020,00000040,00000080,00000100,00000200
B3=00000400,00000800,00001000,00002000,00004000
B4=00008000,00010000,00020000,00040000,00080000
S/C/A=04000000,08000000,10000000

Any attempt to use a BUTTON5 constant name or BUTTONn_RESERVED_EVENT constant name fails:

Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> print("B5={:08x}".format(curses.BUTTON5_RELEASED))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'curses' has no attribute 'BUTTON5_RELEASED'
>>> print("B5={:08x}".format(curses.BUTTON1_RESERVED_EVENT))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'curses' has no attribute 'BUTTON1_RESERVED_EVENT'

When I actually capture mouse wheel events, the wheel-up event is reported as 0x00010000 or BUTTON4_PRESSED, but the wheel-down event is reported as 0x 00200000, which has no constant name associated with it for which I can find any documentation.

This is a logging trace if curses.get_wch() and curses.getkey() results and the curses.getmouse() results when KEY_MOUSE is returned. I have manually annotated the getmouse display lines indicating what mouse action I actually performed.

DEBUG:root:wch='539' = 0x021b at (0,0)
DEBUG:root:3ch='KEY_MOUSE at (0,0)'
DEBUG:root:3ch KEY_MOUSE detected at (0,0)
DEBUG:root:Mouse data id=0, x=60, y=31, z=0, bs=00000004 Button 1 click
DEBUG:root:wch='539' = 0x021b at (0,0)
DEBUG:root:3ch='KEY_MOUSE at (0,0)'
DEBUG:root:3ch KEY_MOUSE detected at (0,0)
DEBUG:root:Mouse data id=0, x=-1, y=-1, z=0, bs=00010000 wheel up once
DEBUG:root:wch='539' = 0x021b at (0,0)
DEBUG:root:3ch='KEY_MOUSE at (0,0)'
DEBUG:root:3ch KEY_MOUSE detected at (0,0)
DEBUG:root:Mouse data id=0, x=-1, y=-1, z=0, bs=00200000 wheel down once
DEBUG:root:wch='539' = 0x021b at (0,0)
DEBUG:root:3ch='KEY_MOUSE at (0,0)'
DEBUG:root:3ch KEY_MOUSE detected at (0,0)
DEBUG:root:Mouse data id=0, x=-1, y=-1, z=0, bs=00010000 wheel up once
DEBUG:root:wch='539' = 0x021b at (0,0)
DEBUG:root:3ch='KEY_MOUSE at (0,0)'
DEBUG:root:3ch KEY_MOUSE detected at (0,0)
DEBUG:root:Mouse data id=0, x=-1, y=-1, z=0, bs=00200000 wheel down once

Where can I find any documentation of the correct curses constant name(s) to use for detecting a "wheel down" action? Or do I just have to manually define my own BUTTON5 constant name for the wheel-down event?

TIA for any help or RTFM you can provide.

Peter

@stephanosio stephanosio added the question Further information is requested label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants