-
Notifications
You must be signed in to change notification settings - Fork 0
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 click events #2
Comments
The only hitch to doing a click queue is the fact that for some reason down/up/double-click/etc states (for event hooking, in particular) are also expected to be handled. Maybe we implement an event system similar to how Web JS handles the DOM? |
I don't know how JS handles DOM, could you elaborate? |
I probably meant the DOM Events API exposed to JS in web browsers; mousedown, mouseup, dragstart, click, rightclick, etc, anything that can be attached via addEventListener. |
You want to use Events system? Event objects and Listeners? |
If it's doable, absolutely. WAY easier for a scripter to hook into an existing event listening system than for them to reimplement it themselves. |
I think we could design a generic event system so it could also be used for game events. If that is wanted? (It could also be in some third party game library). What kind of listening system do we want? I know one from Cocoa: function Event(type, data) {
this.type = type
this.data = data;
}
var kb = Input.Keyboard;
var listenerID = kb.addEventListener(mask, function(event) {
console.log("Received event: "+event);
}
kb.removeEventListener(listenerID)
// or
listenerID.destroy() // listenerID being an object |
I would just as soon keep keyboard and mouse events (and other events) in separate queues, or at least have them fetched discretely. As elegant as a universal event queue is, I don't really see as much use for a game. When you want keyboard or mouse input, you want that input. You don't want to have to deal with replacing or filtering events when you don't get the kind you want. That sounds like it would be a nice feature of perhaps the underlying API implementation, and exposed in that way. I would much rather this be a suggestion or option than a part of the set API. |
So every event-sending object has separate queues: Keyboard.on(), Mouse.on(), etcetera. And then there is Game.on() for custom stuff: Keyboard.on('keydown',function(key) {
// my keydown code
// no need to do filtering. And the function storage is near the using object.
}); |
Or |
I dont see how that would work, but I do see that it does not allow for multiple listeners, a very important feature. You could ofcourse add some static variables that represent strings, so that .on(KeyDown, function(){}) can be used...
|
In Sphere 1.x, only isButtonpPressed is provided. We could use a mouse click event queue.
Idea from @FlyingJester
The text was updated successfully, but these errors were encountered: