使用jTopo給Html5 Canva中繪制的元素添加鼠標事件
來源:易賢網 閱讀:2193 次 日期:2014-07-14 10:20:55
溫馨提示:易賢網小編為您整理了“使用jTopo給Html5 Canva中繪制的元素添加鼠標事件”,方便廣大網友查閱!

使用Html5的時候,在Canvas上繪制的東西是不能相應鼠標事件的,但是使用jTopo添加事件非常簡單,效果如下:

代碼示例:

代碼如下:

var node = new JTopo.Node("Hello");

node.setLocation(409, 269);

node.mousedown(function(event){

if(event.button == 2){

node.text = '按下右鍵';

}else if(event.button == 1){

node.text = '按下中鍵';

}else if(event.button == 0){

node.text = '按下左鍵';

}

});

node.mouseup(function(event){

if(event.button == 2){

node.text = '松開右鍵';

}else if(event.button == 1){

node.text = '松開中鍵';

}else if(event.button == 0){

node.text = '松開左鍵';

}

});

node.click(function(event){

console.log("單擊");

});

node.dbclick(function(event){

console.log("雙擊");

});

node.mousedrag(function(event){

console.log("拖拽");

});

node.mouseover(function(event){

console.log("mouseover");

});

node.mousemove(function(event){

console.log("mousemove");

});

node.mouseout(function(event){

console.log("mouseout");

});

更多信息請查看IT技術專欄

更多信息請查看網頁制作

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網