On Tue, Sep 30, 2008 at 4:10 PM, abel.zhangyu <[EMAIL PROTECTED]>wrote:

>   Hi All,
> I am a SVG newbie. i just created following quite simple svg
> document and expect when the mouse is clicking on rectangle 'test3', i
> can get the rectangle 'test3' from event's target attribute. but the
> actual result is either evt.target or evt.currentTarget always return
> rectangle 'test2' object.
>
> could you explain why it always returns 'test3' instead of 'test2'?
> thank you very much!
>
> <svg viewBox="0 0 1024 768" width="100%" height="100%"
> xmlns="http://www.w3.org/2000/svg";
> xmlns:xlink="http://www.w3.org/1999/xlink"; zoomAndPan="disable"
> xml:space="preserve">
> <script>
> <![CDATA[
>
> function showCoord(evt) {
> alert(evt.target.getAttribute("id") + " source:" +
> evt.currentTarget.getAttribute("id") + " phase:" + evt.eventPhase );
> }
> ]]>
> </script>
>
> <g id="canvas">
> <g id="xxxx">
> <rect id="test4" x="145" y="95" width="105" height="105"
> style="fill:none"/>
> <rect id="test3" x="150" y="100" width="100" height="100"
> fill="blue"/>
> </g>
> <rect id="test2" x="0" y="0" width="100%" height="100%"
> onclick="showCoord(evt)" pointer-events="all" style="fill:none"/>
>
> </g>
> </svg>
>
>  
>

You are painting last rectangle with full screen --  x="0" y="0"
width="100%" height="100%"
and its style is none ... You are unable to see it,, but when ever you are
clicking ,, this rectangle is receiving the event,,So you will always get,,
some alert message correspond to rect2

Try This,,


<g id="canvas">
        <rect id="test2" x="0" y="0" width="100%" height="100%"
onclick="showCoord(evt)" pointer-events="all" fill="green"/>
        <g id="xxxx">
        <rect id="test4" x="100" y="100" width="100" height="100"
fill="yellow" onclick="showCoord(evt)"/>
        <rect id="test3" x="250" y="250" width="100" height="100"
fill="blue" onclick="showCoord(evt)"/>
        </g>
</g>


-- 
‚€€€[ Narendra Sisodiya ]€€€€€€€€€€€€€€ƒ
     http://narendra.techfandu.org
     http://www.lug-iitd.org
     http://twitter.com/eduvid
„€€€€€€€€€€€€[ +91-93790-75930 ]€€€€€€…


[Non-text portions of this message have been removed]


------------------------------------

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to