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

mouse support #7

Open
jquast opened this issue Mar 25, 2014 · 2 comments
Open

mouse support #7

jquast opened this issue Mar 25, 2014 · 2 comments

Comments

@jquast
Copy link
Owner

jquast commented Mar 25, 2014

this was already done once before in a rejected blessings patch last year,

https://asciinema.org/a/2871 <- scroll wheel
https://asciinema.org/a/2866 <- click detection

https://gist.github.com/jquast/7018509#file-__init__-py-L511-L536

Not so sure about the given solution, I need to be persuaded about the context manager names and possible keyword argument/values.

Furthermore, the "Keystroke" class type returned by Terminal.inkey() can now return MouseEvent as well -- they now need to derive from the same base class, providing the same .code and .is_sequence() methods. I think I would further like attribute "kind" of values "MouseEvent" or "keystroke".

Mouse input provides (x,y) attributes, but even bounding box attributes etc., a class needs to be made to support all such decoding, example of decoding and game is done here ("drawing boxes" demo)

https://gist.github.com/jquast/7018509#file-test_mouse-py-L259-L356

@maybeetree
Copy link

Is there still no way to track mouse events? I tried manually enabling mouse tracking with escape sequences and parsing the sequences that inkey() returns. It works fine until I click on a spot where the x or y coordinate is bigger than 127, and that makes blessed throw an exception, because the getch() method tries to decode the bytes representing the coordinates as unicode, and fails.

I really want to be able to track mouse events from my application, so if someone could tell me a way to do it, I would be very grateful.

@jquast
Copy link
Owner Author

jquast commented Nov 2, 2020

It is possible — I’m sorry I can’t help write any code for some time, I’m a bit busy this holiday, but I referenced all of the code that could be stitched together into a PR and I would be happy to accept any good one with tests and docs!

Best wishes, hope you are working on something fun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants