Re: python curses constant names for mouse wheel movements?

2021-03-09 Thread Alan Gauld via Python-list
On 09/03/2021 01:05, pjfarl...@earthlink.net wrote:
> I am replying to my own message due to the digest not appearing in my inbox
> yet today.  I will add Alan Gould's responses and my reply to him manually.

> Yes, when I talk about wheel up/down I do mean wheel rotation events, not
> wheel-button-down or up click events.  The latter are correctly reported by
> the PDCurses implementation used by windows-curses V2.2.0 as BUTTON2 events.
> 
> Christoph Gohlke gave me this link to the current-version PDCurses
> implementation definitions for the mouse state constants, which I found very
> helpful:
> 
> https://github.com/wmcbrine/PDCurses/blob/master/curses.h#L199
> 
> The PDCurses names defined there are exactly what I needed to see, even if
> the current cpython and windows-curses implementations do not support them
> quite yet.  I can safely define them myself and adjust my code as later
> releases of cpython and windows-curses are updated to support them natively.

Thanks, I've done some tests and I see the events as

WHEEL FORWARD - 0x1  or curses.BUTTON4_PRESSED
WHEEL BACK- 0x20   but not defined in the curses module

That's using ncurses on Linux.
Do you get the same mask value under PDcurses on Windows?

I suspect in the real world I'd probably create my own
definitions as WHEEL_FORWARD and WHEEL_BACKWARD just for
readability.

> This link to an ncurses man page concerning mouse events is also
> instructive:
> 
> https://invisible-island.net/ncurses/man/curs_mouse.3x.html

Thanks for that, I hadn't spotted that there was a mouse man
page before...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


RE: python curses constant names for mouse wheel movements?

2021-03-08 Thread pjfarley3
I am replying to my own message due to the digest not appearing in my inbox
yet today.  I will add Alan Gould's responses and my reply to him manually.

alan.gauld at yahoo.co.uk wrote:

> > 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?
>
> I suspect you need to look in the ncurses documentation or
> even the C code. And that is no guarantee that the Python
> curses module will expose any values you do find other
> than as numeric codes.
>
> I would have expected the mouse wheel down/click to appear as
> a BUTTON2 event to be honest. I didn't even realize there was
> a BUTTON4 event defined let alone BUTTON5.
>
> Incidentally, when you talk about wheel up/down are you
> talking about wheel rotation events rather than actual
> button down/up events? In that case 4 and 5 might make sense.
>
> If you find the answer please post back, I'm very interested
> since I'm in the middle of writing a book on the Python curses
> module and was unaware of this behaviour. A whole new area
> to explore I'm also interested in any documentation you
> have already found on it - where did you get this understanding?

Alan,

Yes, when I talk about wheel up/down I do mean wheel rotation events, not
wheel-button-down or up click events.  The latter are correctly reported by
the PDCurses implementation used by windows-curses V2.2.0 as BUTTON2 events.

Christoph Gohlke gave me this link to the current-version PDCurses
implementation definitions for the mouse state constants, which I found very
helpful:

https://github.com/wmcbrine/PDCurses/blob/master/curses.h#L199

The PDCurses names defined there are exactly what I needed to see, even if
the current cpython and windows-curses implementations do not support them
quite yet.  I can safely define them myself and adjust my code as later
releases of cpython and windows-curses are updated to support them natively.

This link to an ncurses man page concerning mouse events is also
instructive:

https://invisible-island.net/ncurses/man/curs_mouse.3x.html

On that page, he says:

   The  ALL_MOUSE_EVENTS  class  does  not  include
REPORT_MOUSE_POSITION.
   They are distinct.  For example, in xterm,  wheel/scrolling  mice
send
   position  reports  as  a  sequence of presses of buttons 4 or 5
without
   matching button-releases.

With python 3.8.7 and windows-curses 2.2.0 I am seeing from my logging that
the mouse wheel rotation up/down events are indeed reported by PDCurses (and
presumably by ncurses on a *ix system) as BUTTON4_PRESSED and
BUTTON5_PRESSED respectively, based on the constant values listed in the
PDCurses link above.

HTH

Peter
--

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python curses constant names for mouse wheel movements?

2021-03-07 Thread Alan Gauld via Python-list
On 07/03/2021 07:16, pjfarl...@earthlink.net wrote:

> 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?

I suspect you need to look in the ncurses documentation or
even the C code. And that is no guarantee that the Python
curses module will expose any values you do find other
than as numeric codes.

I would have expected the mouse wheel down/click to appear as
a BUTTON2 event to be honest. I didn't even realize there was
a BUTTON4 event defined let alone BUTTON5.

Incidentally, when you talk about wheel up/down are you
talking about wheel rotation events rather than actual
button down/up events? In that case 4 and 5 might make sense.

If you find the answer please post back, I'm very interested
since I'm in the middle of writing a book on the Python curses
module and was unaware of this behaviour. A whole new area
to explore I'm also interested in any documentation you
have already found on it - where did you get this understanding?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list