onclick - Add onRightClick to JavaScript lib Hypertree -
i'm working (a repo here) on hypertree graph, want use javascript infovis toolkit. issue follows: added specific events hypertree, onclick
, onrightclick
.
events: { enable: true, onclick: function(node, eventinfo, e) { ht.controller.oncomplete(); }, onrightclick: function(node, eventinfo, e) { ht.controller.oncomplete(); }, },
then attached veent handlers hypertree labels, modifying demo-code little:
//attach event handlers , add text //labels. method triggered on label //creation oncreatelabel: function(domelement, node){ domelement.innerhtml = node.name; $jit.util.addevent(domelement, 'click', function () { ht.onrightclick(node.id, { oncomplete: function() { ht.controller.oncomplete(); } }); }); $jit.util.addevent(domelement, 'rclick', function () { ht.onclick(node.id, { oncomplete: function() { ht.controller.oncomplete(); } }); }); },
that's pretty straight forward. documentation hypertree events in options.events.js. load page... , have left.clicks. no right clicks... want rightclicks move graph , onclicks open link dom element node. can please give me pointer here?
best, marius
$jit.util.addevent(obj, type, fn) shortcut obj.addeventlistener(type, fn, false). trying bind 'onrclick' event. there no such event in javascript. detecting right click need replace 'rclick' 'mouseup', , in callback should check button right one. here code:
$jit.util.addevent(domelement, 'mouseup', function (event) { // detecting right button if (event.button != 2) { return; } ht.onclick(node.id, { oncomplete: function() { ht.controller.oncomplete(); } }); });
also don't need use options.events.js purpose, can remove code
Comments
Post a Comment