Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update empty-release event protocol
  • Loading branch information
huchenlei committed Jul 30, 2024
commit 3b8ac294cd28c7e834003a09c663bd3defec7cd8
14 changes: 13 additions & 1 deletion src/litegraph.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,24 @@ export type LinkReleaseContext = {
type_filter_out?: string;
};

export type ConnectingLink = {
node: LGraphNode;
slot: number;
input: INodeInputSlot | null;
output: INodeOutputSlot | null;
pos: Vector2;
};

export type LinkReleaseContextExtended = {
links: ConnectingLink[];
};

export type LiteGraphCanvasEventType = "empty-release" | "empty-double-click";

export type LiteGraphCanvasEvent = CustomEvent<{
subType: string;
originalEvent: Event,
linkReleaseContext?: LinkReleaseContext;
linkReleaseContext?: LinkReleaseContextExtended;
}>;

export const LiteGraph: {
Expand Down
22 changes: 12 additions & 10 deletions src/litegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -6825,24 +6825,26 @@ LGraphNode.prototype.executeAction = function(action)
}
} else {
const firstLink = this.connecting_links[0];

const linkReleaseContext = this.connecting_output ? {
node_from: this.connecting_node,
slot_from: this.connecting_output,
type_filter_in: this.connecting_output.type
const linkReleaseContext = firstLink.output ? {
node_from: firstLink.node,
slot_from: firstLink.output,
type_filter_in: firstLink.output.type
} : {
node_to: this.connecting_node,
slot_from: this.connecting_input,
type_filter_out: this.connecting_input.type
node_to: firstLink.node,
slot_from: firstLink.input,
type_filter_out: firstLink.input.type
};
// For external event only.
const linkReleaseContextExtended = {
links: this.connecting_links,
};

this.canvas.dispatchEvent(new CustomEvent(
"litegraph:canvas", {
bubbles: true,
detail: {
subType: "empty-release",
originalEvent: e,
linkReleaseContext,
linkReleaseContextExtended,
},
}
));
Expand Down