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

Code cleanup for held mouse buttons #1546

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions plugin/mouse/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,14 @@ def mouse_wake():
def mouse_drag(button: int):
"""Press and hold/release a specific mouse button for dragging"""
# Clear any existing drags
self.mouse_drag_end()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was surprised this even worked. We should definitely call Talon actions through the action interface.

actions.user.mouse_drag_end()

# Start drag
ctrl.mouse_click(button=button, down=True)

def mouse_drag_end():
"""Releases any held mouse buttons"""
buttons_held_down = list(ctrl.mouse_buttons_down())
for button in buttons_held_down:
for button in ctrl.mouse_buttons_down():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ctrl.mouse_buttons_down() returns set[int]. No need to wrap in a list.

ctrl.mouse_click(button=button, up=True)

def mouse_sleep():
Expand All @@ -151,11 +150,7 @@ def mouse_sleep():

show_cursor_helper(True)
stop_scroll()

# todo: fixme temporary fix for drag command
button_down = len(list(ctrl.mouse_buttons_down())) > 0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is basically a recreation of the logic in mouse_drag_end, but worse.

if button_down:
ctrl.mouse_click(button=0, up=True)
actions.user.mouse_drag_end()

def mouse_scroll_down(amount: float = 1):
"""Scrolls down"""
Expand Down