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

MouseScrollUp/MouseScrollDown => plain MousEvent's #1458

Merged
merged 7 commits into from
Jan 5, 2023

Conversation

nitzan-shaked
Copy link
Contributor

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

Copy link
Collaborator

@willmcgugan willmcgugan left a 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.

screen_x=x,
screen_y=y,
)
event_cls = (
Copy link
Collaborator

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.

if buttons & 32
else (events.MouseDown if state == "M" else events.MouseUp)
)
if event_cls in (events.MouseScrollUp, events.MouseScrollDown):
Copy link
Collaborator

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.

else (events.MouseDown if state == "M" else events.MouseUp)
)
if event_cls in (events.MouseScrollUp, events.MouseScrollDown):
buttons &= ~(64 | 3)
Copy link
Collaborator

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.
@nitzan-shaked
Copy link
Contributor Author

nitzan-shaked commented Jan 2, 2023

@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.

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@willmcgugan willmcgugan merged commit 0a35013 into Textualize:main Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants