showConnectionMenu with searchbox options (#111)

* showConnectionMenu with searchbox options

* nit
This commit is contained in:
Chenlei Hu
2024-09-03 13:07:38 -04:00
committed by GitHub
parent bcd3c6b30f
commit 85076881c8
2 changed files with 25 additions and 16 deletions

11
public/litegraph.d.ts vendored
View File

@@ -1537,7 +1537,16 @@ export declare class LGraphCanvas {
callback: Function,
event: any
): HTMLDivElement;
showSearchBox(event?: MouseEvent): void;
showSearchBox(event?: MouseEvent, options?: LinkReleaseContext): void;
showConnectionMenu(optPass?: {
nodeFrom?: LGraphNode;
slotFrom?: INodeSlot | string | number;
nodeTo?: LGraphNode;
slotTo?: INodeSlot | string | number;
e?: MouseEvent;
allow_searchbox?: boolean;
showSearchBox?: (event?: MouseEvent, options?: LinkReleaseContext) => void;
}): void;
showEditPropertyValue(node: LGraphNode, property: any, options: any): void;
createDialog(
html: string,

View File

@@ -7651,13 +7651,13 @@ const globalExport = {};
};
this.canvas.dispatchEvent(new CustomEvent(
"litegraph:canvas", {
bubbles: true,
detail: {
subType: "empty-release",
originalEvent: e,
linkReleaseContext: linkReleaseContextExtended,
},
}
bubbles: true,
detail: {
subType: "empty-release",
originalEvent: e,
linkReleaseContext: linkReleaseContextExtended,
},
}
));
// add menu when releasing link in empty space
if (LiteGraph.release_link_on_empty_shows_menu) {
@@ -11319,7 +11319,9 @@ const globalExport = {};
,
slotTo: null // output
,
e: null
e: null,
allow_searchbox: this.allow_searchbox,
showSearchBox: this.showSearchBox,
},
optPass
);
@@ -11330,7 +11332,7 @@ const globalExport = {};
if (!isFrom && !isTo) {
console.warn("No data passed to showConnectionMenu");
return false;
return;
}
var nodeX = isFrom ? opts.nodeFrom : opts.nodeTo;
@@ -11354,12 +11356,12 @@ const globalExport = {};
// bad ?
//iSlotConn = 0;
console.warn("Cant get slot information " + slotX);
return false;
return;
}
var options = ["Add Node", null];
if (that.allow_searchbox) {
if (opts.allow_searchbox) {
options.push("Search");
options.push(null);
}
@@ -11399,9 +11401,9 @@ const globalExport = {};
break;
case "Search":
if (isFrom) {
that.showSearchBox(e, { node_from: opts.nodeFrom, slot_from: slotX, type_filter_in: fromSlotType });
opts.showSearchBox(e, { node_from: opts.nodeFrom, slot_from: slotX, type_filter_in: fromSlotType });
} else {
that.showSearchBox(e, { node_to: opts.nodeTo, slot_from: slotX, type_filter_out: fromSlotType });
opts.showSearchBox(e, { node_to: opts.nodeTo, slot_from: slotX, type_filter_out: fromSlotType });
}
break;
default:
@@ -11419,8 +11421,6 @@ const globalExport = {};
break;
}
}
return false;
}
// refactor: there are different dialogs, some uses createDialog some dont
prompt(title, value, callback, event, multiline) {