W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: ECMAScript binding for EventListener

From: Dylan Schiemann <dylans@yahoo.com>
Date: Fri, 15 Jun 2001 08:46:06 -0700 (PDT)
Message-ID: <20010615154606.46322.qmail@web13504.mail.yahoo.com>
To: Jim Ley <jim@jibbering.com>
Cc: www-dom@w3.org

--- Jim Ley <jim@jibbering.com> wrote:
> It's not a lot of different, it's still reasonably
> neat.   I don't see
> the point in making things more complicated for no
> reason, keep the
> implementation simple, and small, and fast and only
> add features that are
> truly of value, I'm still unsure as to exactly where
> this would be of
> particular value - are there any non trivial
> examples?

My purpose was for capturing click events, and
rerouting double and triple clicks.  The idea was to
capture all clicks to a generic method of a class for
handling events, and then reroute the event based on
the detail property.  If you want to do this is an
object-oriented manner, you must do something like
Jeff's suggestion, or add an attribute to the element
the event is fired upon which has a reference to
"this" for the object itself.  For the latter,
something like:

function EventHandlerClass(el)
{
   this.el = element
   this.el.backPointer = this
}

function addEventListeners()
{
  
this.el.addEventHandler("click",this.singleClick,false);
}
EventHandlerClass.prototype.addEventListeners =
addEventListeners;

function singleClick(e)
{
   if(e.detail==2) this.backPointer.doubleClick(e);
  //
}
EventHandlerClass.prototype.singleClick = singleClick;

function doubleClick(e)
{
   //
}
EventHandlerClass.prototype.doubleClick = doubleClick;

The current behavior seems to have redundancy between
"this" and the first argument passed in an event. 
What benefit does "this" provide that you couldn't get
just as easily from a property or method on the event
argument?

-Dylan Schiemann


__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
Received on Friday, 15 June 2001 11:46:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT