wws
October 28, 2022, 8:55pm
1
Just curious – Is there a way to edit TreeView cells like it was a spreadsheet?
Still on my long, backburned path to make a “tracker” input for SC with midi input.
Also – I hope no on feels obligated to write a bunch of code for their response. I am mostly curious, hoping for a pointer to docs if it’s possible.
TXMod
October 28, 2022, 9:35pm
2
Yes, by putting NumberBox views in the cells, for example:
(
t = TreeView().front;
t.columns_(["one", "two", "three"]);
t.addItem(["Alice", "Anna", "Anders"]);
t.addItem(["Bob", "Beatrice", "Benny"]);
t.addItem(["Cleo", "Conrad", "Cecilia"]);
i = t.itemAt(1); //get an item
i.setView(0, NumberBox());
i.setView(1, NumberBox());
i.setView(2, NumberBox());
i.view(1).value_(44);
i.view(2).value_(99);
)
see: TreeViewItem | SuperCollider 3.12.2 Help
wws
October 28, 2022, 10:05pm
3
Oh that’s fantastic, thank you!
Is the paradigm to fill the TreeView with Qt views as you might need? For the tracker project, I would want to use text strings, maybe with a validation thing.
I would also need to process all the data within the TreeView items into a single array of arrays that could drive a sequence, but that just seems like some looping and coding.
ty!
TXMod
October 29, 2022, 4:49pm
4
That sound right. You can add actions to the views to get the behaviour you want:
(
t = TreeView().front;
t.columns_(["one", "two", "three"]);
t.addItem(["Alice", "Anna", "Anders"]);
t.addItem(["Bob", "Beatrice", "Benny"]);
t.addItem(["Cleo", "Conrad", "Cecilia"]);
i = t.itemAt(1); //get an item
i.setView(0, TextField());
i.setView(1, NumberBox());
i.setView(2, NumberBox());
i.view(0).string_("text...");
i.view(1).value_(44);
i.view(2).value_(99);
i.view(0).action_({arg view; view.string.postln;});
i.view(1).action_({arg view; view.string.postln;});
i.view(2).action_({arg view; view.string.postln;});
)