You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Andreas Neumann <ne...@karto.baug.ethz.ch> on 2006/05/17 17:06:28 UTC

tracking event listeners

Hello,

When I develop more complex SVG applications I sometimes have problems 
tracking the state of event listeners that I add and remove as needed 
using .addEventListener() and .removeEventListener()

I wonder if there is a way to find out whether an event listener is 
currently attached to an element (e.g. the document.documentElement), 
either by using the JS debugger in squiggle or by writing out something 
to the console.

It would help me a lot finding my bugs.

Thanks for any feedback on that problem,
Andreas

-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: tracking event listeners

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Andreas.

Andreas Neumann:
> When I develop more complex SVG applications I sometimes have problems 
> tracking the state of event listeners that I add and remove as needed 
> using .addEventListener() and .removeEventListener()
> 
> I wonder if there is a way to find out whether an event listener is 
> currently attached to an element (e.g. the document.documentElement), 
> either by using the JS debugger in squiggle or by writing out something 
> to the console.
> 
> It would help me a lot finding my bugs.

If these are added from script, then no, there’s no easy way to check
what functions have been added.  This is because the wrapper class to
turn an ECMAScript function object (or string) into an EventListener
does not expose the underlying script object.  If you wanted, you could
modify
org.apache.batik.script.rhino.EventTargetWrapper.FunctionEventListener
to provide a method to expose the Function.

To get access to the EventListeners that have been registered on an
EventTarget, you can do:

  var n = …; // an EventTarget
  var es = n.getEventSupport(); // an o.a.b.dom.events.EventSupport
  var ell = es.getEventListeners(eventType, useCapture);
      // an o.a.b.dom.events.EventListenerList
  var listeners = ell.getEventListeners(); // an Object[]
  for (var i = 0; i < listeners.length; i++) {
    var listener = listeners[i];

  }

-- 
 Cameron McCormack			ICQ: 26955922
 cam (at) mcc.id.au			MSN: cam (at) mcc.id.au
 http://mcc.id.au/			JBR: heycam (at) jabber.org

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org