- added hook for slot context menu

This commit is contained in:
Stefan Rinke
2020-04-23 00:07:18 +02:00
parent 6ff8bb700d
commit ac1d8f8f71
2 changed files with 24 additions and 18 deletions

1
src/litegraph.d.ts vendored
View File

@@ -932,6 +932,7 @@ export declare class LGraphNode {
): boolean;
/** Called by `LGraphCanvas.processContextMenu` */
getMenuOptions?(graphCanvas: LGraphCanvas): ContextMenuItem[];
getSlotMenuOptions?(slot: INodeSlot): ContextMenuItem[];
}
export type LGraphNodeConstructor<T extends LGraphNode = LGraphNode> = {

View File

@@ -10081,6 +10081,9 @@ LGraphNode.prototype.executeAction = function(action)
if (slot) {
//on slot
menu_info = [];
if (node.getSlotMenuOptions) {
menu_info = node.getSlotMenuOptions(slot);
} else {
if (
slot &&
slot.output &&
@@ -10100,6 +10103,8 @@ LGraphNode.prototype.executeAction = function(action)
? "Cannot rename"
: { content: "Rename Slot", slot: slot }
);
}
options.title =
(slot.input ? slot.input.type : slot.output.type) || "*";
if (slot.input && slot.input.type == LiteGraph.ACTION) {