Skip to main content
Inspiring
May 28, 2010
Answered

More control over UndoManager

  • May 28, 2010
  • 1 reply
  • 537 views

Hi,

I want to control how the undomanager works, specifically, how the un-do operatiosn are performed. I want to be able to un-do text entered by the users letter by letter or workd by word. How can this be done?

Secondly, would that have a impact on performance? let's say we keep a atack of 50 operations in the undopmanager.

tks.

This topic has been closed for replies.
Correct answer Aaronius9er9er

Check out EditManager.finalizeDo() where it says:

if (_undoManager.canUndo() && allowOperationMerge)                          {                               var lastOp:FlowOperation = _undoManager.peekUndo() as FlowOperation;                               if (lastOp)                               {                                    // Try to merge the last operation on the stack with the current                                    // operation. This may modify lastOp, or return a new operation                                    var combinedOp:FlowOperation = lastOp.merge(op);                                    if (combinedOp)                                    {                                         combinedOp.setGenerations(lastOp.beginGeneration,textFlow.generation);                                         _undoManager.popUndo();                                         op = combinedOp;                                    }                               }                          }

That's where it's doing the combining of each letter.  You might be able to get away with setting allowOperationMerge to false.  Or override the function and take this part out.  I'm not sure what other consequences those options will have though as I haven't tried it.  The UndoManager is simple; you mainly will want to dig into EditManager.

1 reply

Aaronius9er9er
Aaronius9er9erCorrect answer
Inspiring
May 28, 2010

Check out EditManager.finalizeDo() where it says:

if (_undoManager.canUndo() && allowOperationMerge)                          {                               var lastOp:FlowOperation = _undoManager.peekUndo() as FlowOperation;                               if (lastOp)                               {                                    // Try to merge the last operation on the stack with the current                                    // operation. This may modify lastOp, or return a new operation                                    var combinedOp:FlowOperation = lastOp.merge(op);                                    if (combinedOp)                                    {                                         combinedOp.setGenerations(lastOp.beginGeneration,textFlow.generation);                                         _undoManager.popUndo();                                         op = combinedOp;                                    }                               }                          }

That's where it's doing the combining of each letter.  You might be able to get away with setting allowOperationMerge to false.  Or override the function and take this part out.  I'm not sure what other consequences those options will have though as I haven't tried it.  The UndoManager is simple; you mainly will want to dig into EditManager.