Reputation: 331
using the basic tutorial here as example: https://dojotoolkit.org/documentation/tutorials/1.10/menus/demo/simpleProgMenu.html
I've noticed that there's no (obvious) way to differentiate between left and right clicks. I'd like right click to do nothing, but left click to call the onClick() on the menuitem.
Inspecting the contents of the event parameter passed to the onClick function, there doesn't appear to be anything telling me which mouse button was clicked.
Is there a way to achieve this?
Upvotes: 0
Views: 124
Reputation: 725
If you want right click to do nothing, you don't have to do anything special. If you want to handle right clicks you can use the dojo/mouse module and its mouseButtons object. An example from the documentation:
require(["dojo/mouse", "dojo/on", "dojo/dom"], function(mouse, on, dom){
on(dom.byId("someid"), "click", function(evt){
if (mouse.isLeft(event)){
// handle mouse left click
}else if (mouse.isRight(event)){
// handle mouse right click
}
});
});
Upvotes: 1