Add LGraphNode.getExtraSlotMenuOptions hook (#522)

This commit is contained in:
Chenlei Hu
2025-02-12 15:52:27 -05:00
committed by GitHub
parent 9abcf0fd32
commit 361a1a76ef
2 changed files with 12 additions and 0 deletions

View File

@@ -7393,6 +7393,10 @@ export class LGraphCanvas implements ConnectionColorContext {
}
if (!_slot.nameLocked)
menu_info.push({ content: "Rename Slot", slot: slot })
if (node.getExtraSlotMenuOptions) {
menu_info.push(...node.getExtraSlotMenuOptions(slot))
}
}
// @ts-expect-error Slot type can be number and has number checks
options.title = (slot.input ? slot.input.type : slot.output.type) || "*"

View File

@@ -458,7 +458,15 @@ export class LGraphNode implements Positionable, IPinnable {
canvasElement: HTMLCanvasElement,
): void
onMouseLeave?(this: LGraphNode, e: CanvasMouseEvent): void
/**
* Override the default slot menu options.
*/
getSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[]
/**
* Add extra menu options to the slot context menu.
*/
getExtraSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[]
// FIXME: Re-typing
onDropItem?(this: LGraphNode, event: Event): boolean
onDropData?(