• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Undo Stack

Guest
May 17, 2011 May 17, 2011

Copy link to clipboard

Copied

Hi,

I have run into a situation where I wouls want to update the text of a span not by copy pasting a textscrap or any other known means ,

instead by directly updating the text property

eg

somespan.text="my new text";

By doing so I am not able to undo this change

editMgr.undoManager.undo();

does nothing when I undo this.

Eg:

Initial Span <someSpan>enter your name</somSpan>

after setting the text property

someSpan.text="my new text";

Now if I try to undo the span back to "enter your name" by editMgr.undoManager.undo();

it doesnt happen so.
Thanks
Ashar
TOPICS
Text layout framework

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , May 18, 2011 May 18, 2011

If you use InsertTextOperation to moidfy the span then that will be an undoable operation.  You can use BeginCompositeOperation/EndCompositeoperation APIs to group operations.

Richard

Votes

Translate

Translate
Adobe Employee ,
May 17, 2011 May 17, 2011

Copy link to clipboard

Copied

The UndoManager class manages the history of editing operations on a text flow so that these operations can be undone and redone.

The undo manager maintains two stacks of IOperation objects. When a reversible operation is executed, it is placed on the undo stack. If that operation is undone, it is removed from the undo stack, reversed, and placed on the redo stack. Likewise, if that operation is then redone, it is removed from the redo stack, re-executed, and then placed onto the undo stack again. If another operation is executed first, the redo stack is cleared.

(This paragraph can answer your question)
If the TextFlow is modified directly (not via calls to the edit manager, but directly via calls to the managed FlowElement objects), then the edit manager clears the undo stack to prevent the stack from getting out of sync with the current state.

From code,

        public function undo():void
        {
            // Cancel out of an IME session if there is one.
            // Some IMEs are on all the time, and so the undo has to win over the IME,
            // otherwise you would never be able to undo in Korean.
            if (_imeSession)
                _imeSession.compositionAbandoned();
           
            if (undoManager)
                undoManager.undo();
        }


Your operation can be undone only when you input words through input methods or the undoManager is initialized.

Since there is no imeSession in your case, you can have a look at when undoManager is not null.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 18, 2011 May 18, 2011

Copy link to clipboard

Copied

If you use InsertTextOperation to moidfy the span then that will be an undoable operation.  You can use BeginCompositeOperation/EndCompositeoperation APIs to group operations.

Richard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2011 May 19, 2011

Copy link to clipboard

Copied

Yes Richards I am now using insertTextOperation it is rightly the undoable operation I was looking for.

-Ashar

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2011 May 19, 2011

Copy link to clipboard

Copied

Thanks Jin for the detailed explanation and helping me out in approaching towards a workaround..

-Ashar

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2011 May 19, 2011

Copy link to clipboard

Copied

LATEST

One more requirement is to update a user style and still have the undo stack in place.

Currently I am doing :

flowElement.required="false";but this deleted every thing from the undo stack.

so I want to do something like

var tlf:TextLayoutFormat= new TextLayoutFormat();

tlf.required="false";

flowElement.getTextFlow().interactionManager.selectRange(

flowElement.getAbsoluteStart(),

flowElement.getAbsoluteStart()+ flowElement.textLength);

IEditManager(flowElement.getTextFlow().interactionManager).applyLeafFormat(tlf);

However there will not be anything like tlf.required since "required" is a user style

Is there a work around to get the above done?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines