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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]