On Binding Events

9 views
Skip to first unread message

Kevin Palis

unread,
Aug 7, 2011, 12:26:26 PM8/7/11
to The Render Engine
Hello Brett,

I started using the beta version (2.0.0.10) a few days ago and started
implementing some event-handling. I noticed that in the mouse events,
simply writing the onMouseDown(), onMouseMove(), etc, doesn't work
unlike the onKeyDown(), onKeyUp(), and onKeyPress() of the Keyboard
component. However, upon looking at how you wrote the physics demo, I
added something like to bind the handlers:
this.addEvent("mouseup", function(evt, info) {
self.onmouseDown(false, info);
});
and then it worked (for the onmouseDown method at least, the onClick
method still didn't work, which is weird). However, I tried updating
to the master branch from github earlier to check if the event
handling is already uniform, but unfortunately, my code stopped
working. So I had to revert back to 2.0.0.10. I then took a closer
look on what have changed, and apparently, there was the "* Added
methods to simplify event wiring" commit.

So my question is, how should I really write my handlers (particularly
on mouse events)? I'm a bit lost on the differences on how the
handlers are setup/implemented on the examples. As of now, the only
events that I was able to bind successfully to the handlers are
mousedown and the keyboard events. I'm not sure why the other events
won't work.

Thanks!
Reply all
Reply to author
Forward
0 new messages