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 Michael Gale <mi...@bitflash.com> on 2002/03/06 00:34:07 UTC

Element identification

Hi,

Using Batik's classes, can we determine what DOM element has been
clicked/selected by the mouse?  Does someone know where an example can be
found?  Does every GraphicsNode need to listen for mouse events?  Is there a
quick way to register the elements for the events?

Thanks for your time,
Michael

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


Re: Element identification

Posted by Vincent Hardy <vi...@sun.com>.
Michael,

You can certainly do what you are asking by adding listeners to the 
DOM. This will ensure that your handler is called when a given 
element is the target of an event.

For example:

<svg ....>

<script ....>

function callMe(evt){
    alert('You called me');
}

</script>

   <circle cx="50%" cy="50%" r="25%" fill="crimson"
onclick="callMe(evt)" />

</svg>

To listen to events on the GVT Tree, we are using an EventDispatcher
to which you can add listeners, but if you are looking at finding 
out which DOM element has been clicked, the right place to add your
listeners is the DOM.

Note that the above should work with 1.1.1, but you'll get a much
better support for scripting in the upcoming beta release.

Vincent.

Michael Gale wrote:
> 
> Hi,
> 
> Using Batik's classes, can we determine what DOM element has been
> clicked/selected by the mouse?  Does someone know where an example can be
> found?  Does every GraphicsNode need to listen for mouse events?  Is there a
> quick way to register the elements for the events?
> 
> Thanks for your time,
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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


RE: Element identification

Posted by Thierry Kormann <tk...@ilog.fr>.
> Using Batik's classes, can we determine what DOM element has been
> clicked/selected by the mouse?  Does someone know where an example can be
> found?  Does every GraphicsNode need to listen for mouse events?
> Is there a
> quick way to register the elements for the events?

Use the DOM (org.w3c.dom.events).

Register EventListener to the element you are interested in and your
listener will be invoke depending on the event type.

Example:

EventTarget evtTarget = (EventTarget) elt;
evtTarget.addEventListener("click", myListener, false);

Hope that helps,
Thierry.


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