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.
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:
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:
Thanks