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

Mouse click events #2

Open
joskuijpers opened this issue Mar 28, 2014 · 10 comments
Open

Mouse click events #2

joskuijpers opened this issue Mar 28, 2014 · 10 comments
Labels

Comments

@joskuijpers
Copy link
Contributor

In Sphere 1.x, only isButtonpPressed is provided. We could use a mouse click event queue.

Idea from @FlyingJester

@apollolux
Copy link
Member

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?

@joskuijpers
Copy link
Contributor Author

I don't know how JS handles DOM, could you elaborate?

@apollolux
Copy link
Member

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.

@joskuijpers
Copy link
Contributor Author

You want to use Events system? Event objects and Listeners?

@apollolux
Copy link
Member

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.

@joskuijpers
Copy link
Contributor Author

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

@FlyingJester
Copy link
Member

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.

@joskuijpers
Copy link
Contributor Author

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.
});

@FlyingJester
Copy link
Member

Or key.down = function(){}. I prefer not using string literals like that.

@joskuijpers
Copy link
Contributor Author

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...

On May 10, 2014, at 11:50 PM, Martin McDonough [email protected] wrote:

Or key.down = function(){}. I prefer not using string literals like that.


Reply to this email directly or view it on GitHub.

@joskuijpers joskuijpers reopened this May 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants