Ai
1 Star 0 Fork 1

ComfyUI CustomNodes Clone/ComfyUI-Custom-Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
useNumberInputPrompt.js 922 Bytes
一键复制 编辑 原始数据 按行查看 历史
pythongosssss 提交于 2023-10-01 20:15 +08:00 . Allow prompt to use number input
import { app } from "../../../scripts/app.js";
const id = "pysssss.UseNumberInputPrompt";
const ext = {
name: id,
async setup(app) {
const prompt = LGraphCanvas.prototype.prompt;
const setting = app.ui.settings.addSetting({
id,
name: "🐍 Use number input on value entry",
defaultValue: false,
type: "boolean",
});
LGraphCanvas.prototype.prompt = function () {
const dialog = prompt.apply(this, arguments);
if (setting.value && typeof arguments[1] === "number") {
// If this should be a number then update the imput
const input = dialog.querySelector("input");
input.type = "number";
// Add constraints
const widget = app.canvas.node_widget?.[1];
if (widget?.options) {
for (const prop of ["min", "max", "step"]) {
if (widget.options[prop]) input[prop] = widget.options[prop];
}
}
}
return dialog;
};
},
};
app.registerExtension(ext);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/custom_nodes_clone/ComfyUI-Custom-Scripts.git
git@gitee.com:custom_nodes_clone/ComfyUI-Custom-Scripts.git
custom_nodes_clone
ComfyUI-Custom-Scripts
ComfyUI-Custom-Scripts
main

搜索帮助