in reply to Re^2: Mouse action using SVG
in thread Mouse action using SVG

Why not try?

SVG module is real simple, its just helpers to generate some xml

The "mouseaction" seems like something extra the author needed , its not part of the spec

Anyway,

$rctangle->attrib( onclick => q{alert(evt);});

https://www.w3.org/TR/SVG/script.html
https://www.w3.org/TR/SVG/images/script/script01.svg

 

Also, I cross-link cross-postings for maximum collaboration efficiency

http://stackoverflow.com/questions/38667654/mouse-action-svg

Replies are listed 'Best First'.
Re^4: Mouse action using SVG
by Ezhil4663 (Novice) on Jul 30, 2016 at 18:40 UTC
    It doesn't seem to work for me. I want to show the message which is stored in $message when I click the rectangle. I modified the code this way.
    $svg->rectangle( x =>$x1, y =>$y1, width => $x2, height => $y2, style => { 'fill' => 'rgb(0, 0, 128)', 'stroke' => 'black', 'stroke-width' => 1, 'stroke-opacity' => 1, 'fill-opacity' => 1, }, ); $rectangle->attrib(onclick=>q{alert($message);});
    Please correct me if I am wrong

      Of course that doesn't work. Did you look at the debug "console" of your browser to check for javascript errors? Why not? Did you look at the HTML that was produced/sent? Why not?

      After you've done that, you might also want to read the subtread at Re^7: perl dancer route template hashref pass complex json file to server issue (escape/filter).

      I'm not going to post code that I think will work for this case yet, as I think it is important for you to think more about this aspect of the problem before being handed code.

      - tye