2016-07-29 46 views
-1

任何人都可以请给我一个简单的例子,使用svg的鼠标动作?我在网上找不到任何好的示例。我想单击矩形时显示一条消息。我正在使用SVG模块来开发图形。鼠标动作SVG

+0

crosspost at http://perlmonks.com/?node_id=1168835 –

回答

0

该文档有点稀疏,但您可以随时咨询软件包的测试文件以获取灵感。

https://github.com/szabgab/SVG/blob/master/t/09-script.t

吨/ 09-script.t - 线39-49

my $rect = $svg->rect(
    x  => 10, 
    y  => 10, 
    fill => 'red', 
    stroke => 'black', 
    width => '10', 
    height => '10', 
    onclick => "alert('hello'+' '+'world')" 
); 

$out = $rect->xmlify; 

产生SVG代码段

<rect fill="red" height="10" onclick="alert('hello'+' '+'world')" stroke="black" width="10" x="10" y="10" /> 

其它鼠标操作可以类似地包括在键/值对列表中。属性的完整列表:SVG Attribute Reference