Hello JUCE family.
I have now hopped onto the
UndoManager train to make data manipulation, Undo/Redo, and serialization a bit easier.
Right now I have a
Button and I want it to toggle a boolean value in my
ValueTree. To do this, I setup the
Button to toggle it’s internal
Value on click, and I make sure the internal
Value of the
Button references the corresponding
Value in my
ValueTree. Also, I have an
UndoManager that is connected to the
ValueTree properties via
To connect the
Button with my
UndoManager, I’ve used the following lines:
// Clicking will toggle the boolean of the internal `Value` object myButton.setClickingTogglesState (true); // The `Button's` internal toggle `Value` should reference a property in my `ValueTree` myButton.getToggleStateValue().referTo (myValueTree.getPropertyAsValue (myPropertyIdentifier, myUndoManager));
My problem is: if I make multiple clicks on my
Button, all clicks get grouped into a single transaction in my
UndoManager. So, if my
Button started in a true toggle state, then I clicked the button four times in a row, reaching a true toggle state again, and then I called
undoManager.undo(), all of the clicks would be undone, bringing the toggle state back to true instead of false. I want each click to be an independent transaction. Is there a connection I am missing?
I know I could just get a callback with
Button::Listener every time the button is clicked and add it to the
UndoManager history with
myUndoManager.beginNewTransaction(), but I thought there might be a more automatic solution.