Skip to content

Commit

Permalink
Merge pull request #312 from RareDevil/IncorrectlyOpenOtherContextMenu
Browse files Browse the repository at this point in the history
Fixed a problem where the contextmenu would open another menu
  • Loading branch information
bbrala committed Nov 16, 2015
2 parents 5402ab0 + d4bea06 commit e46c389
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/jquery.contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@
if ((e.data.trigger !== 'right' && e.data.trigger !== 'demand') && e.originalEvent) {
return;
}

// Let the current contextmenu decide if it should show or not based on its own trigger settings
if (e.mouseButton !== undefined && e.data) {
if (!(e.data.trigger == 'left' && e.mouseButton === 0) && !(e.data.trigger == 'right' && e.mouseButton === 2)) {
// Mouse click is not valid.
return;
}
}

// abort event if menu is visible for this trigger
if ($this.hasClass('context-menu-active')) {
Expand Down Expand Up @@ -468,7 +476,7 @@

if (target && triggerAction) {
root.$trigger.one('contextmenu:hidden', function () {
$(target).contextMenu({x: x, y: y});
$(target).contextMenu({ x: x, y: y, button: button });
});
}

Expand Down Expand Up @@ -1355,7 +1363,7 @@
if (operation === undefined) {
this.first().trigger('contextmenu');
} else if (operation.x !== undefined && operation.y !== undefined) {
this.first().trigger($.Event('contextmenu', {pageX: operation.x, pageY: operation.y}));
this.first().trigger($.Event('contextmenu', { pageX: operation.x, pageY: operation.y, mouseButton: operation.button }));
} else if (operation === 'hide') {
var $menu = this.first().data('contextMenu') ? this.first().data('contextMenu').$menu : null;
$menu && $menu.trigger('contextmenu:hide');
Expand Down

0 comments on commit e46c389

Please sign in to comment.