I’ve found a number of cases recently where I needed more control over what actually happens with Undo/Redo on my ValueTree data. As such, I’ve come up with the following class, and figured i’d play sharey.

It’s a ValueSource class you can use to wrap any value (not just one from a ValueTree), to get customisable Undo/Redo functionality.

  • It uses a default UndoableAction which simply sets the target value. However, this can be overridden for more specific needs (e.g. if you need to perform some kind of admin task on both perform AND undo)
  • You can override shouldCreateNewTransaction() [which is called before an operation is applied] to control whether or not a new transaction should be started [it currently defaults to true, i.e. always start a new transaction, because that’s what I need more often at the moment].

One important thing to be aware of is that, if wrapping a Value from a ValueTree, you must take a ‘non-undo’ Value [i.e., myTree.getPropertyAsValue(id,[b]0[/b])] - as the undo is now handled by the wrapper!




I can’t access and download it