Ron King wrote:
I guess I didn't make myself clear. When I click, I'm not getting the path element back. I saw a thread talking about how thin a path is, causing it to not be 'clickable'. Is this true? Do I have to use the graphicsnode interface to capture a click on an area enclosed by a path? If so, exactly how is this done?
A couple of things. First be careful what 'target' you are looking at, a UI event can have up to _three_. For your mouse clicks I would expect the following values to be returned: evt.getCurrentTarget -> SVGSVGElement evt.getTarget -> SVGPathElement evt.getRelatedTarget -> null (or Exception).
So make absolutely sure you are using getTarget not getCurrentTarget (current target is the element the event is being dispatched to target is the 'source' of the event). In fact I know you must be using getCurrentTarget as an 'svg' element can never be the 'source' of a UI event.
Second if the path is not 'filled' (i.e. fill="none") then you can use the 'pointer-events' property to adjust the sensitivity of the path to events (check the SVG specification for complete info).
----- Original Message ----- From: "Weiming Zhang" <[EMAIL PROTECTED]>
To: "Batik Users" <[EMAIL PROTECTED]>
Sent: Friday, November 14, 2003 10:58 AM
Subject: Re: trouble adding eventlistener to Squiggle
Hi,
I used: ((Element)event.getTarget()).setAttribute("fill", "yellow");
wz On Thu, 2003-11-13 at 17:16, Ron King wrote:
Thanks Thomas! I see events now! However, my svg files consist of many
path
elements, and the type returned by the event is a SVGOMSVGElement. For a painting function, I need to be able to change the fill attribute of a path. How
can
I get the path element by clicking inside of the area enclosed by the
path?
Thanks, Ron
----- Original Message ----- From: "Thomas DeWeese" <[EMAIL PROTECTED]>
To: "Batik Users" <[EMAIL PROTECTED]>
Sent: Thursday, November 13, 2003 4:45 AM
Subject: Re: trouble adding eventlistener to Squiggle
Ron King wrote:
Hi All,
I've looked for an example of handling events, but I still can't
figure
it out! I made the method below to add a listener for _EACH_ path in an svg file (I'm doing this in Batik Squiggle, after a document is loaded):
You probably need to tell squiggle to load your document as a dynamic document: canvas.setDocumentState(JSVGCanvs.ALWAYS_DYNAMIC) Normally if Batik doesn't see event attributes or script elements it assumes it is a static document. This must be done before the document is loaded.
Additionally you may want to look into: getElementsByTagNameNS to get the path elements. You should probably check for SVGPathElement not SVGOMPathElement (our internal implementation), finally you already have the element why are you looking it up by 'id'? Just cast it to an EventTarget.
EventTarget t = (EventTarget) (e.getSVGDocument().getElementById(pathId)); t.addEventListener("click", onClick, true);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]