angular-contextmenu icon indicating copy to clipboard operation
angular-contextmenu copied to clipboard

able to change menu with left click

Open itsmill3rtime opened this issue 10 years ago • 1 comments

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 avatar Jan 19 '16 03:01 itsmill3rtime

@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 :)

zweeen avatar Sep 30 '16 15:09 zweeen