jQuery-contextMenu
jQuery-contextMenu copied to clipboard
[Suggestion] Context menu without selector
Hello, I see that selector is mandatory. But for example, in my case, I use canvas so there isn't anything to select with jquery selector because objects in canvas are unselectable with jquery. Could we use context menu without selector (If selector isn't available then position should be required)
A selector is mandatory, but perhaps canvas
would be fine. You can manually open the menu with a command (see https://swisnl.github.io/jQuery-contextMenu/docs/plugin-commands.html#manually-show-a-contextmenu) and you can send the page x/y with it.
Would that suffice?
@bbrala Well yeah, I worked around it. But I created another element for this job other than using canvas for it. Because I need multiple context menu for single canvas and some objects have the same context menu. I suggest something like;
let context = $.contextMenu({ opts });
context.contextMenu({ pos: { x:val, y:val} );
Instead of:
const dummyElement = "#dummy";
$.contextMenu({
selector: dummyElement,
position: function(opt, x, y){
var jqObj = $(dummyElement);
opt.$menu.css({top: jqObj.data("y"), left: jqObj.data("x")});
},
opts..
});
var jqObj = $(dummyElement);
jqObj.data("x", getCurrentX());
jqObj.data("y", getCurrentY();
jqObj.contextMenu();
Hmm, yeah, that would be helpfull. I can't give an estimate right now though when i would have the time to get this up and running.