Disable right click menu for context menu event. [Perspective 8.0.9]

I have a component with an onContextMenu event, which has a popup event action. Is there a way to prevent the right click menu from appearing?

Not through Perspective as of right now. There is a simple Javascript command you could run ( document.body.setAttribute("oncontextmenu", "return false"); ) from within the browser’s console, but Perspective doesn’t have access to that part of the browser.

2 Likes

I disabled the right click context menu within Chrome by creating an extension as described in the 3rd reply by Quik in this forum post.
https://community.spiceworks.com/topic/2116359-disable-right-click-context-menu-on-chrome

The only edit I made was to change from ‘all_urls’ to the IP address of my server in the json file

"matches": ["http://my.server.ip/*"],

Currently I’ve created the extension for one user on a client system and it works well. Not sure if it can be set generically for all users on a client system.

Since this was bumped - in 8.0.15 you can add a mouse event handler that has “Prevent Default” set:

1 Like

On Igntion 8.1.9 “Prevent Default” don’t work.

I just tested using “Prevent Default” to prevent context menus in both 8.1.9 and 8.1.10, and it worked exactly as expected in both versions. If you’re experiencing different behavior @Mau89 , please provide a detailed example and/or replication steps.

On a label in a view, I configured a “onClick” event with a minimal script (print in console)

and it don’t work, when I click with right button on label it showed popmenu of browser.
I am testing on Firefox (91.0.2) and on Chrome (92.0.4515.15)

Your “Event” is for a standard click, not a right-click. If you want to prevent the context menu, you need to prevent default for onContextMenu.

So “onClick” event work only with left button?

Not exactly. An onContextMenu event is, by definition, what opens the popup menu in the browser. You have to intercept that event type if you want to prevent the default context menu behavior. This is all up to browsers and Javascript, not something Ignition/Perspective came up with: