-
Notifications
You must be signed in to change notification settings - Fork 128
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
Mouse keys #90
Comments
Hello! If you mean that you would like to use function buttons on your mouse to trigger Phoenix, you can usually use the driver software for your mouse to rebind those buttons to a custom keyboard shortcut. Then you can bind that shortcut with Phoenix. Would that help? |
I actually want to check in javascript if the mouse button is up or down. Is there a way to check that? |
Ah, I see. There’s currently no way to determine that, but I presume it would be possible. Could you describe how you would use this? |
I am trying to implement a window snap feature and like to know, if the
|
Right, so you’re presumably listening to the I’ll think about how we could support mouse events in the future. |
Sounds great! Thanks for the tip using debounce. :) 2016-05-06 10:57 GMT+02:00 Kasper Hirvikoski notifications@github.com:
|
You’re most welcome. Let me know if you need more help with debounce. |
I noticed |
@mafredri Darn, you’re right! I completely forgot it obviously uses Nevertheless, Phoenix does support timing functions, check out |
I took a stab at implementing the timeout/interval API for Phoenix. It also fixes the underscore debounce functionality :). Maybe of interest to you @oleic? I tried to keep it simple, whilst removing the explicit requirement on keeping references to your handlers (when using setTimeout / setInterval). (function(global) {
// Keeps references to Phoenix handlers
var refs = new Set();
// Add functions on the global object
global.setTimeout = setTimeout;
global.clearTimeout = clear;
global.setInterval = setInterval;
global.clearInterval = clear;
function setTimeout(fn, interval) {
var handler = Phoenix.after(interval / 1000, handleFn);
refs.add(handler);
return handler;
function handleFn() {
fn();
refs.delete(handler); // Delete reference after completion
}
}
function setInterval(fn, interval) {
var handler = Phoenix.every(interval / 1000, fn);
refs.add(handler);
return handler;
}
function clear(handler) {
handler.stop(); // Stop the timer immediately
refs.delete(handler);
}
})(this); |
@mafredri Nice! I think we should add |
I agree, it would make sense to support all functionality of Underscore since it comes bundled! And also, supporting commonly used APIs makes it more fluent to use Phoenix :). |
I’ve added support for the following mouse events to Phoenix. Others can be added provided they are useful. Interestingly, there doesn’t seem to be any distinction between “down” and “up” with global mouse events. Both are triggered when the click is released — so I’ve only provided the up events. This feature will be released in 2.2.
|
Hey,
is it possible to get mouse keys available?
The text was updated successfully, but these errors were encountered: