-
Notifications
You must be signed in to change notification settings - Fork 826
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
MouseScrollUp/MouseScrollDown => plain MousEvent's #1458
Conversation
07a7e9a
to
e834b7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine in principle, but needs a refactor for readability.
src/textual/_xterm_parser.py
Outdated
screen_x=x, | ||
screen_y=y, | ||
) | ||
event_cls = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many nested ternary operators here, which makes the logic hard to follow. Suggest refactoring it in to simpler conditions and statements.
src/textual/_xterm_parser.py
Outdated
if buttons & 32 | ||
else (events.MouseDown if state == "M" else events.MouseUp) | ||
) | ||
if event_cls in (events.MouseScrollUp, events.MouseScrollDown): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is checking something that we only just assigned in the previous statement. Suggest if we need to do something different, we should to it in the branch where event_cls
is assigned.
src/textual/_xterm_parser.py
Outdated
else (events.MouseDown if state == "M" else events.MouseUp) | ||
) | ||
if event_cls in (events.MouseScrollUp, events.MouseScrollDown): | ||
buttons &= ~(64 | 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need to modify buttons after it is assigned.
... which means they get passesd x, y, etc. In particular, they are passed the keyboard modifiers. This allows widgets to use e.g. ctrl-wheel to scroll right/left.
e834b7a
to
0b249bd
Compare
@willmcgugan I changed the code to fix all 3 of your comments above. I admit I like it less that way, but if you like it better then I'm happy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
... which means they get passesd x, y, etc. In particular, they are passed the keyboard modifiers. This allows widgets to use e.g. ctrl-wheel to scroll right/left.