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 Lawrence Michel <la...@swissonline.ch> on 2007/03/12 00:16:32 UTC
Handling SVG element onclick event
Hello community,
I'm actually quite new in using Batik. Unfortunately, I was unable to
find any useful help over the internet.
- I have a Swing Java Application containing a JSVGCanvas. The SVG is
loaded and printed properly.
- The SVG has some graphical elements containing onclick attributes.
How can I (the java application) be notified about each Events triggered
by an SVG element?
The idea behind this is that I would like to have this event being
handled and dispatched from a custom build java class, which will be
responsible to update, for example, another Swing window content (let's
say a JTextArea.append("new event from "+TARGET_ELEMENT+" of type
"+EVENT_TYPE) ).
Thanks for your help ;-)
Best regards
Lawrence Michel
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Handling SVG element onclick event
Posted by th...@kodak.com.
Hi Lawrence,
Lawrence Michel <la...@swissonline.ch> wrote on 03/11/2007
07:16:32 PM:
> I'm actually quite new in using Batik. Unfortunately, I was unable to
> find any useful help over the internet.
>
> - I have a Swing Java Application containing a JSVGCanvas. The SVG is
> loaded and printed properly.
> - The SVG has some graphical elements containing onclick attributes.
>
> How can I (the java application) be notified about each Events triggered
> by an SVG element?
You can register a event listener on the root SVG element using
DOM Events (addEventListener). Note that a listener on the root of
the SVG tree receives _all_ events of the kind your request so you
may need to filter to just your elements.
You can also register listeners on just about any single element
but it sounds like registering one listener on the root element is
what you want.
> The idea behind this is that I would like to have this event being
> handled and dispatched from a custom build java class, which will be
> responsible to update, for example, another Swing window content (let's
> say a JTextArea.append("new event from "+TARGET_ELEMENT+" of type
> "+EVENT_TYPE) ).
All our DOM events are dispatched in our UpdateManager's thread
so you need to make sure to call over to the swing thread to run
your swing update code.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org