Account for upstream links when refreshing combo widgets

This commit is contained in:
space-nuko
2023-05-16 20:55:20 -05:00
parent 0d6395c072
commit 9f1da40385
14 changed files with 1436 additions and 129 deletions

View File

@@ -0,0 +1,48 @@
import { BuiltInSlotType, LiteGraph, type SlotLayout } from "@litegraph-ts/core";
import ButtonWidget from "$lib/widgets/ButtonWidget.svelte";
import ComfyWidgetNode, { type ComfyWidgetProperties } from "./ComfyWidgetNode";
export interface ComfyButtonProperties extends ComfyWidgetProperties {
param: string
}
export default class ComfyButtonNode extends ComfyWidgetNode<boolean> {
override properties: ComfyButtonProperties = {
tags: [],
defaultValue: false,
param: "bang"
}
static slotLayout: SlotLayout = {
outputs: [
{ name: "clicked", type: BuiltInSlotType.EVENT },
]
}
override svelteComponentType = ButtonWidget;
override defaultValue = false;
override outputSlotName = null;
override changedEventName = null;
constructor(name?: string) {
super(name, false)
}
override parseValue(param: any): boolean {
return Boolean(param);
}
onClick() {
this.setValue(true)
this.triggerSlot(0, this.properties.param);
this.setValue(false) // TODO onRelease
}
}
LiteGraph.registerNodeType({
class: ComfyButtonNode,
title: "UI.Button",
desc: "Button that triggers an event when clicked",
type: "ui/button"
})