(name: string, value: string | number | boolean | object | undefined)
| 7310 | panel.addHTML("<h3>Properties</h3>") |
| 7311 | |
| 7312 | const fUpdate = (name: string, value: string | number | boolean | object | undefined) => { |
| 7313 | if (!this.graph) throw new NullGraphError() |
| 7314 | this.graph.beforeChange(node) |
| 7315 | switch (name) { |
| 7316 | case "Title": |
| 7317 | if (typeof value !== "string") throw new TypeError("Attempting to set title to non-string value.") |
| 7318 | |
| 7319 | node.title = value |
| 7320 | break |
| 7321 | case "Mode": { |
| 7322 | if (typeof value !== "string") throw new TypeError("Attempting to set mode to non-string value.") |
| 7323 | |
| 7324 | const kV = Object.values(LiteGraph.NODE_MODES).indexOf(value) |
| 7325 | if (kV !== -1 && LiteGraph.NODE_MODES[kV]) { |
| 7326 | node.changeMode(kV) |
| 7327 | } else { |
| 7328 | console.warn(`unexpected mode: ${value}`) |
| 7329 | } |
| 7330 | break |
| 7331 | } |
| 7332 | case "Color": |
| 7333 | if (typeof value !== "string") throw new TypeError("Attempting to set colour to non-string value.") |
| 7334 | |
| 7335 | if (LGraphCanvas.node_colors[value]) { |
| 7336 | node.color = LGraphCanvas.node_colors[value].color |
| 7337 | node.bgcolor = LGraphCanvas.node_colors[value].bgcolor |
| 7338 | } else { |
| 7339 | console.warn(`unexpected color: ${value}`) |
| 7340 | } |
| 7341 | break |
| 7342 | default: |
| 7343 | node.setProperty(name, value) |
| 7344 | break |
| 7345 | } |
| 7346 | this.graph.afterChange() |
| 7347 | this.dirty_canvas = true |
| 7348 | } |
| 7349 | |
| 7350 | panel.addWidget("string", "Title", node.title, {}, fUpdate) |
| 7351 |
nothing calls this directly
no test coverage detected