feature request[?]: Event information not available for callback functions
Hi there! I'd like to ask for a feature, which might come handy to many: It would be great if the callback function could have a third parameter, which contains the triggered event. As event object is available as a global variable in the real browsers (Firefox doesn't count as one!), it's easy to determine if the callback event is triggered using control buttons or right click of the mouse, but as mentioned, because the lovely firefox lacks this global variable, it's not possible to determine event information in callback function. as an example, please refer to the following code
callback: function (key, options/*, event would be great as third parameter */)
{
var $button = $(options.$trigger);
var _this = defaults._findThis(options, key);
if(typeof event !== 'undefined' && event.ctrlKey)
{
// start dancing around the browser
}
else
{
// do the normal thing
}
}
Thanks for your interest, i'll visit this in the next round of features. :)
Hmm, was wandering through the code and saw this code;
callback.call(root.$trigger, key, root, e)
seems the fourth argument is event right now.
It is indeed possible to get the event back from the callback. Additionally, x/y trigger coords are attached to the event passed back. However, after working with this plugin, i found the best way to get the most control is to run context menu via a manual trigger event, and run async/deferred. Check out https://pastebin.com/kxPpSNry for an example. I realize it's a big chunk of code to take in, so if it's too much, just checkout contextmenus documentation on asyncronous creation.