You can use the contextmenu
event to detect right clicks as described in the earlier answer. Another way to detect clicks for the right mouse button is jquery's event.which:
clickTree: function(e) {
if (event.which === 3) {
// handle right clicks
this.showtreemenu(e);
return;
}
// handle left clicks
this.toggletree(e);
}
For long clicks, aka measuring click duration, use mouseup
and mousedown
:
events: {
'mousedown .measure-click-duration': 'clickStarted',
'mouseup .measure-click-duration': 'clickEnded'
},
clickStarted: function(e) {
this.clickStartTime = e.timeStamp;
},
clickEnded: function(e) {
var clickDuration = e.timeStamp - this.clickStarted;
if (clickDuration > 1000) {
this.longClick(e);
}
}
I made a fiddle demonstrating contextmenu
for right clicks and the click duration described above.