jQuery-contextMenu icon indicating copy to clipboard operation
jQuery-contextMenu copied to clipboard

[Suggestion] Context menu without selector

Open sarpaykent opened this issue 6 years ago • 3 comments

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)

sarpaykent avatar Dec 06 '17 20:12 sarpaykent

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 avatar Dec 07 '17 14:12 bbrala

@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();

sarpaykent avatar Dec 07 '17 19:12 sarpaykent

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.

bbrala avatar Dec 11 '17 12:12 bbrala