Chris
Chris

Reputation: 2907

Disable NSUndoManager grouping invocations on document load

NSUndoManager groups invocations together that happen in the same runloop.

I want to load a document that contains the undo history within it.

As such, I create a document and apply the invocations one-by-one, these however all get added very quickly, resulting in a single undo.

Is there a way I can change the NSUndoManagers runloop or something else so that I get separate undo invocations?

I have tried disabling groupsByEvent and creating my own beginUndoGrouping but it doesn't seem to work

Upvotes: 2

Views: 277

Answers (1)

lassej
lassej

Reputation: 6494

Have you tried closing the toplevel group and opening it again after you added your invocations? E.g.:

undoManager.endUndoGrouping()

// add your undo invocations

undoManager.beginUndoGrouping()

Upvotes: 1

Related Questions