swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.24k stars 744 forks source link

Add a "preShow" callback, to conditionally show context menu or not. #669

Open Mike-Benoit opened 5 years ago

Mike-Benoit commented 5 years ago

In our case we want the jquery context menu to appear if the user right-clicks anywhere on the screen, but have the browsers native context menu to appear if they right-click on a textarea, input box, or some other special element of our choosing. One of the main reasons is that if you turn off right-click to get to browser native copy/cut/paste/translate/etc... actions, users seem to complain pretty loudly.

I realize there are ways to get this behavior right now, but from my understanding they are pretty difficult in our case, specifically when the selector is dynamic and where their may be multiple different context menus registered.

As an easy work around, if you could simply register a "preShow" callback (I think jQuery-ui tabs does something like this), that passes in the event, and the current contextmenu object, we could then make any decisions we want and either cause the context menu to appear, not appear, or show the browser native context menu based on the return value of that callback.

bbrala commented 5 years ago

Yeah that is a great idea.

bshafiei-ir commented 5 years ago

I need it too. @bbrala

bbrala commented 5 years ago

I will make some time this week to get going on issues, have been a bit swamped lately.