Skip to content

Commit

Permalink
Prevent right mouse button up event to click on menu item.
Browse files Browse the repository at this point in the history
In some case[*] when we right click on row/col header and release mouse button,
first element of the context menu is invoked accidentally. To prevent this,
just prevent the right mouseup event on context menu item.

[*] 1920x1080 resolution with %75 browser zoom

Signed-off-by: Gülşah Köse <[email protected]>
Change-Id: I28299e7a7cf83eaed27ef4ed6c3555fb2cc80682
  • Loading branch information
GulsahKose authored and pedropintosilva committed Nov 2, 2023
1 parent 557f191 commit 46c1248
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions browser/src/control/Control.ColumnHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export class ColumnHeader extends Header {
this.context.strokeStyle = this._borderColor;
this.context.lineWidth = app.dpiScale;
this.context.strokeRect(startX - 0.5, 0.5, entry.size, this.size[1]);

this._map._contextMenu.stopRightMouseUpEvent();
}

getHeaderEntryBoundingClientRect (index: number): Partial<DOMRect> {
Expand Down
14 changes: 13 additions & 1 deletion browser/src/control/Control.ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,19 @@ L.Control.ContextMenu = L.Control.extend({
}

return contextMenu;
}
},

// Prevents right mouse button's mouseup event from triggering menu item accidentally.
stopRightMouseUpEvent: function() {
var menuItems = document.getElementsByClassName('context-menu-item');

for (var i = 0 ; i < menuItems.length; i++) {
menuItems[i].addEventListener('mouseup', function(e) {
if (e.button == 2) // Is a right mouse button event?
e.stopPropagation();
});
}
}
});

L.control.contextMenu = function (options) {
Expand Down
2 changes: 2 additions & 0 deletions browser/src/control/Control.RowHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export class RowHeader extends cool.Header {
this.context.strokeStyle = this._borderColor;
this.context.lineWidth = app.dpiScale;
this.context.strokeRect(0.5, startY - 0.5, this.size[0], entry.size);

this._map._contextMenu.stopRightMouseUpEvent();
}

getHeaderEntryBoundingClientRect (index: number): Partial<DOMRect> {
Expand Down

0 comments on commit 46c1248

Please sign in to comment.