2016-07-29 50 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