canvas_menu - chrisgoringe/Comfy-Custom-Node-How-To GitHub Wiki
Adding to the canvas menu
The canvas menu is the one you get if you right-click on the background - to add nodes, etc.. You can add to it:
async setup() {
const original_getCanvasMenuOptions = app.canvas.getCanvasMenuOptions; // save the original function
app.canvas.getCanvasMenuOptions = function () {
const options = original_getCanvasMenuOptions.apply(this, arguments); // call the original function
options.push(null); // divider
options.push({
content: `Menu item text`,
disabled: false, // or a function determining whether to disable
callback: () => {
// action when clicked goes in here
}
});
return options; // return the menu options with your custom ones added
}
}