Mouse Event is Not Triggered

In the following example, the callback function is not called when right mouse button is clicked. Left button has no issue.

let table = grok.data.demo.demog();
let view = grok.shell.addTableView(table);
rxjs.fromEvent(view.grid.overlay, ‘click’).subscribe((e) => {

//NEVER CALLED FOR RIGHT MOUSE BUTTON CLICKS

});

This is not a Datagrok issue, you have to subscribe to the ‘contextmenu’ event, just like that:

rxjs.fromEvent(document.body, 'contextmenu').subscribe((e) => {
    grok.shell.info('!@');
});

But I’ve tried that and while it works on the document.body, Datagrok seems to handle this event for all viewers in order to show the custom menu. Stay tuned, we’ll figure out a way to prevent it.

…and just in case you need to customize the default menu, we have just exposed this functionality:

This approach is much better than handling the context menu using mouse events. The only question is how to remove the default menu items? It seems like I can only add new items:
args.args.menu.items([“New Item 1”, “New Item 2”]);

It would be logical to completely override the default context menu by calling

args.preventDefault();

as this is done for cell renders in Grid viewer.

That makes perfect sense; we’ll introduce the missing methods, and will make sure the menu appearance could be prevented as well.

That’d be great to have! There is another small issue with the context menu.

The statement below appends the items to the context menu only for right mouse clicks originated from regular Grid cells. For column header cells the statement is ignored.

args.args.menu.items([“New Item 1”, “New Item 2”]);

We’ve just added the following method for the Menu class: find, remove, and clear. Here are the sources (latest version will be deployed on dev in an hour):