Closed dirkx closed 1 year ago
My compliments for flow; very neat & easy to keep the data model in sync with the UI & lovely editing for the wires.
But am wondering if an example is needed that shows how to add a node (or delete) at runtime.
I had expected something like below to be possible - but am clearly missing something obvious.
import SwiftUI import Combine import Flow @main struct FlowDemoApp: App { var fcv = FlowContentView.init() var body: some Scene { WindowGroup { // FlowContentView() fcv; } .commands { CommandMenu("Nodes") { Button(action: { // fcv.addNode(); let newNode = Node(name: "PID", titleBarColor: Color.red, inputs: ["in1", "in2"], outputs: ["out"]); fcv.patch.nodes.append(newNode) }, label: { Text("Add Node") }); } } } }
Adding something to the example that adds a node would be most lovely
Tried various other options (obviously recreating and redrawing works)
No response
@dirkx I added a button in the demo. I suspect there's a problem with your code because it seems to store a view as a var.
Perfect & clear ! Thanks.
Description
My compliments for flow; very neat & easy to keep the data model in sync with the UI & lovely editing for the wires.
But am wondering if an example is needed that shows how to add a node (or delete) at runtime.
I had expected something like below to be possible - but am clearly missing something obvious.
Proposed Solution
Adding something to the example that adds a node would be most lovely
Describe Alternatives You've Considered
Tried various other options (obviously recreating and redrawing works)
Additional Context
No response