FR: UndoManager::deleteCurrentAction


I want to ask for a feature request for the UndoManager class:
It should be possibel to delete the current action.
At the moment, it is only possible to delete the current transaction, by using “UndoManager::undoCurrentTransactionOnly”. But a transaction can have several actions inside it. So deleting the current transaction would be too much. I only want to delete the latest action.

My use case: I perform an action, check if anything has changed, and if no changes are made, I want to discard that action.

Yeah… I’m not crazy about the idea of adding that.

Have you considered using UndoableAction::createCoalescedAction()? If what you’re trying to do is to avoid there being redundant actions in the list, that’s the system for compacting them.

Hi Jules,

Thanks for your answer.
Can I use that command to compactify the list of actions in the UndoManager? By that I mean actions, which already have been added to the current transaction?
If yes, then it would help indeed.

Well yes - that’s exactly the point of that method!

If you have an action like e.g. dragging a value around, where each mouse-move changes it, there’s no sense in storing all those changes, so this allows it to throw away the useless actions.

Or, if you use ValueTrees then it’ll take care of this for you, as it automatically uses this technique to compact sequential property changes.