I have had a good look on the forum and couldn’t find anything on this, so here’s a question.
I am working with Juce and using the ValueTree callbacks to update various parts of my program. In one or two cases, the child nodes represent some objects that I have stored in an array. When a child is removed, the callback is:
void valueTreeChildRemoved (ValueTree& parent, ValueTree& removedChild)
which doesn’t tell me the index of the removedChild node (at least, the index it was at before it was removed), this would be handy so that I can remove the corresponding element from my array. If I ask for:
I get -1, which makes perfect sense, as the child is no longer a node of the parent. And definitely I see the problems with providing an index for something that is no longer in the tree. However, it would be very handy if the callback was something like…
void valueTreeChildRemoved (ValueTree& parent, ValueTree& removedChild, int indexOfTheChildBeforeItWasRemoved)
At present - I have to destroy my entire array and re-populate it from the whole tree, which is inefficient. It’d be much better if I knew which node to remove and could remove it in isolation.
Many thanks in advance for any help!