angular-contextmenu
angular-contextmenu copied to clipboard
able to change menu with left click
in your demo if you right click an item in the table and then left click a different item. the menu stays open but changes to the menu for the item you left click. it doesn't disappear
@itsmill3rtime
You are right, the correct behaviour for a context menu is that it must disappears on left click.. You can do it by changing the "click" event on the "registerMouse" function (look at your contextmenuItem directive ):
So instead of :
iam.element.on('click', function(ev) {
var multi = ev.ctrlKey || ev.metaKey;
ev.preventDefault();
ev.stopPropagation();
ctrl.get().toggle(iam, multi);
scope.$apply();
});
do this :
iam.element.on('click', function(ev) {
var multi = ev.ctrlKey || ev.metaKey;
ev.preventDefault();
ev.stopPropagation();
ctrl.get().close(); // here we use close() instead of toggle()
scope.$apply();
});
You can notice that I called the "close" function instead of "toggle" function. Now the context menu will disapear on left click :)