<snip>
> this.obj.onmousedown = function(evt){
> this.pickup(evt);
> }
> won't work as expected, please help!
In javascript the value of - this - is determined entirely by how a
function is called and has no relationship with how or where code that
uses it is declared/defined. When the browser calls an event handler
assigned to an event handling property of an Element it calls that
handler as a method of the Element, and so - this - is a reference to
the Element.
There are several techniques for associating DOM Element's event
handlers with javascript object instances. Many are based upon
closures:-
<URL: http://jibbering.com/faq/faq_notes/closures.html >
Richard.
nstasiv@gmail.com - 31 Aug 2006 15:36 GMT
As I understand code
this.ctl.getObject().addEventListener("mousedown",
function(evt){this.pickup(evt);}, false);
has the problem where this.pickup(evt); is called. Am I right?
If there is no easy way to do the trick I will dig into closures
subject. Thank you for help!
> <snip>
> > this.obj.onmousedown = function(evt){
[quoted text clipped - 16 lines]
>
> Richard.