W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2001

Re: ECMAScript binding for EventListener

From: Dylan Schiemann <dylans@yahoo.com>
Date: Fri, 15 Jun 2001 08:46:05 -0700 (PDT)
Message-ID: <20010615154605.53043.qmail@web13508.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()
EventHandlerClass.prototype.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

-Dylan Schiemann

Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
Received on Tuesday, 10 July 2001 11:03:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC