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

✨ Support mouse scroll button as trigger key #63

Closed
2 tasks done
caocanx opened this issue Oct 24, 2023 · 9 comments · Fixed by #67
Closed
2 tasks done

✨ Support mouse scroll button as trigger key #63

caocanx opened this issue Oct 24, 2023 · 9 comments · Fixed by #67
Assignees
Labels

Comments

@caocanx
Copy link
Contributor

caocanx commented Oct 24, 2023

Feature Request Description

Then we can just use one hand to trigger loop, it will very convenient.

Screenshots

No response

Additional Context

No response

Final Checks

  • My issue title is descriptive
  • This is a single feature request (multiple feature requests should be reported individually)
@MrKai77 MrKai77 self-assigned this Oct 24, 2023
@MrKai77
Copy link
Owner

MrKai77 commented Oct 24, 2023

Great idea! A caveat is that trackpads can't Middle Click unlike normal mice, so it would probably make sense to make this another dedicated setting, named something like Middle Click to Trigger Loop as a checkbox, instead of being able to set this as the only trigger key, so this is likely what I will do. I'll try and finish this before the next Loop release (hopefully by the end of this week!).

@MrKai77
Copy link
Owner

MrKai77 commented Oct 26, 2023

Alright, I have implemented and tested it! It works really well, and I think I'll be using this daily too! Here's a working build:
Loop.zip
Please let me know if there are any issues you encounter!

@caocanx
Copy link
Contributor Author

caocanx commented Oct 26, 2023

@MrKai77
Copy link
Owner

MrKai77 commented Oct 26, 2023

Great find! However, I am completely unable to reproduce this bug :(
Would you be able to provide a bit more info, such as:

  • Does it happen everytime Loop is triggered with middle click?
  • Does it work fine when directions are selected using Loop's keybinds?

As a bonus, does this latest build fix this bug? I'm expecting that it won't, but it doesn't hurt to try!
Loop.zip (this is from commit 50ff1e9)

@MrKai77
Copy link
Owner

MrKai77 commented Oct 26, 2023

Actually, I was able to reproduce it! Will fix it right now!

@MrKai77
Copy link
Owner

MrKai77 commented Oct 26, 2023

Ok... here's a fixed build! Again, please let me know if you face any other issues!
Loop.zip

@caocanx
Copy link
Contributor Author

caocanx commented Oct 26, 2023

Ok... here's a fixed build! Again, please let me know if you face any other issues! Loop.zip

You fixed it! Thank you!

@caocanx
Copy link
Contributor Author

caocanx commented Oct 26, 2023

A small suggestion. Maybe we can use otherMouseDragged event instead of otherMouseDown event. Because in some usage scenarios, the click action is already used, like:

  1. Click chrome tab to close it.
  2. Click link to open in a new tab

And when we want trigger loop, we also need to drag, so I think use otherMouseDragged maybe a good idea.

I also have some code, hope it can help.

NSEvent.addGlobalMonitorForEvents(matching: NSEvent.EventTypeMask.otherMouseDragged) { event -> Void in
    if event.buttonNumber == 2 {
        self.openLoop()
    }
}
NSEvent.addGlobalMonitorForEvents(matching: NSEvent.EventTypeMask.otherMouseUp) { event -> Void in
    if event.buttonNumber == 2 {
        self.closeLoop()
    }
}

@MrKai77
Copy link
Owner

MrKai77 commented Oct 26, 2023

Ohhhh! Thanks for the code example! I really like this functionality! Now I can close tabs by just middle clicking and Loop a window by dragging while middle clicking! Here's a latest build:
Loop.zip
Please let me know if there's any other improvements you can think of!

EDIT: Note that this build has middle click as trigger key enabled permanently, no matter what the setting is set to. This has been fixed in the next commit :)

MrKai77 added a commit that referenced this issue Oct 26, 2023
@caocanx caocanx closed this as completed Oct 27, 2023
@MrKai77 MrKai77 linked a pull request Oct 27, 2023 that will close this issue
MrKai77 added a commit that referenced this issue Oct 27, 2023
…-as-trigger-key`

✨ #63 Support mouse scroll button as trigger key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants