I have a context menu define din my nwjs app. It has 4 items, including Cut, Paste, Copy, and Select All.
I would like to make the menu more aware of context. For instance, I would like to disable paste if there is nothing in the clipboard.
I am at a loss on how to tackle this. Don't even know where to start. Does anyone have ideas?
I did this where my menu was defined
$(document).on("contextmenu", function (e) {
e.preventDefault();
var clipboard = gui.Clipboard.get();
if (clipboard && clipboard.get('text').length > 0) {
menu.paste.enabled = true;
} else {
menu.paste.enabled = false;
}
menu.popup(e.originalEvent.x, e.originalEvent.y);
});