I have a question regarding the UndoManager. I have a component that can be dragged within the UI, and I want to make that operation undoable. Additionally, if the component was clicked on but not moved I don’t want to add an undo transaction to the undo history. Right now I’m starting a new transaction in the component’s mouseDown method so that the entire drag operation is in a single transaction, but obviously this will cause a new transaction to be added even if the component wasn’t dragged anywhere. I guess what I’m looking for is a method like UndoManager::removeCurrentTransactionFromUndoHistory or some such. How do others handle this scenario?
There’s no overhead in repeatedly calling beginTransaction() - any subsequent calls are ignored unless you’ve actually performed an operation since the last call to it.