-
Notifications
You must be signed in to change notification settings - Fork 245
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
Update mac.py #68
base: master
Are you sure you want to change the base?
Update mac.py #68
Conversation
Add doubleclick() method for doubleclick triggering
What are your thoughts regarding cross-platform compatibility for this change? |
Not exactly sure what you mean, this change is OSX-specific, as far as I know pymouse/mac.py offers functionality exclusively for macs. Method I suggested triggers doubleclicks just fine on my mac, and does what otherwise I was not able to accomplish with this module. |
It contains Mac-specific implementations for a common interface. |
Actually, take a look at the |
Calling You need another method for double-click, because
where clickCount is self-explanatory. There is no straight-forward way of putting that into To be honest, I see no other way of accomplishing that without incorporating unnecessary code into To sum up, like I mentioned, other solutions would require serious modifications to
on one, existing event, before posting it (and modifying and posting it accordingly again to simulate releasing the button and pressing it again). Otherwise it will not trigger a proper action resulting from a double-click like we're all accustomed to. |
The question is if 2 clicks should be different from a double-click. We should think if it makes sense to say something like def click(self, x, y, button=1, n=1):
event = Quartz.CGEventCreateMouseEvent(None,
pressID[button],
(x, y),
button - 1)
Quartz.CGEventSetIntegerValueField(event, Quartz.kCGMouseEventClickState, n)
for i in range(n):
Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)
Quartz.CGEventSetType(event, Quartz.kCGEventLeftMouseUp)
Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)
Quartz.CGEventSetType(event, Quartz.kCGEventLeftMouseDown) |
It might make sense and definitely looks promising, this way there would be a universal method for n amount of clicks, and a method for long press, simple enough without hardcoding just the doubleclick behaviour into a separate method. Please, test your snippet out and let me know if it works for double clicks as intended. |
Added doubleclick() method for doubleclick handling. Calling click() twice does not trigger a proper doubleclick, nor does calling click() with n = 2, or manually calling press(), release() then sleeping for some time and repeating the sequence.