UndoManager in Audio Plugin


#1

Hi everybody,
I use the AudioProcessorValueTreeState to handle all states and changes of my plugin.
Is there a way to hook up the undoManager to the daw so that the CMD-Z from the DAW reaches my plugin?
Or should I capture the key strokes and call undo on the undoManager myself?

And how works the beginNewTransaction? How do I mark the end of a transaction, or do I need to call beginNewTransaction each time, even if my transaction is only a single undoableAction?
Thanks for clarification…
daniel


#2

There’s no way to intercept DAW keystrokes like that - you’d need to just use a KeyListener in your editor component.

A common trick for beginNewTransaction is to restart a Timer each time a value changes, so that when things stop changing for e.g. 1 second, it automatically starts a new transaction, but so that it won’t break up a continuous drag gesture.


#3

Thanks, that’s easy to do, I just thought there might be an interface of the plugin wrapper for undo, but obviously not. But as long as the keys are not customizable it’s no problem. otherwise one could end up having a different undo shortcut in the daw and the plugin…

The timer trick is a good idea, thank you. Maybe it could be added in the AudioProcessorValueTreeState, as there the information is present, if a gesture is pending, and the undo manager is linked there… Or maybe a query method like bool AudioProcessorValueTreeState::hasOpenGestures()?

Just to be sure, the beginNewTransaction simply resets something, it’s no problem to add many calls, if nothing happenes in between?


#4

Doesn’t feel like something that should be in that class, it’s probably not something that would suit everyone.

And yes, call it as often as you like, it’s very cheap.


#5

Well, it would be very useful to be able to query if there are open gestures.

But I came up with another idea, I will check if my plugin window is in the foreground (has focus) and if the mouse is being pressed.