diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 3b324c2d96..f04ced2f37 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -244,7 +244,7 @@ public: return children.indexOf (child.object); } - void addChild (SharedObject* child, int index, UndoManager* undoManager) + ValueTree& addChild (SharedObject* child, int index, UndoManager* undoManager) { if (child != nullptr && child->parent != this) { @@ -283,9 +283,11 @@ public: jassertfalse; } } + + return *this; } - void removeChild (int childIndex, UndoManager* undoManager) + ValueTree& removeChild (int childIndex, UndoManager* undoManager) { if (auto child = Ptr (children.getObjectPointer (childIndex))) { @@ -301,6 +303,8 @@ public: undoManager->perform (new AddOrRemoveChildAction (*this, childIndex, {})); } } + + return *this; } void removeAllChildren (UndoManager* undoManager) diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 8d147a5559..7f1ff8ce46 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -323,14 +323,16 @@ public: If the undoManager parameter is not nullptr, its UndoManager::perform() method will be used, so that this change can be undone. Be very careful not to mix undoable and non-undoable changes! @see appendChild, removeChild + @returns a reference to the value tree, so that you can daisy-chain calls to this method. */ - void addChild (const ValueTree& child, int index, UndoManager* undoManager); + ValueTree& addChild (const ValueTree& child, int index, UndoManager* undoManager); /** Appends a new child sub-tree to this tree. This is equivalent to calling addChild() with an index of -1. See addChild() for more details. @see addChild, removeChild + @returns a reference to the value tree, so that you can daisy-chain calls to this method. */ - void appendChild (const ValueTree& child, UndoManager* undoManager); + ValueTree& appendChild (const ValueTree& child, UndoManager* undoManager); /** Removes the specified child from this tree's child-list. If the undoManager parameter is not nullptr, its UndoManager::perform() method will be used,