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

How Adding an operation queue Undo Redo using addChild from TextFlow ?

New Here ,
Jul 21, 2009 Jul 21, 2009

Hi,

I wanna to add a operation in the queue of operations, when I run the following code.

EditManager(textFlow.interactionManager).beginCompositeOperation()

var para:ParagraphElement = new ParagraphElement();
var spanBullet:SpanElement = new SpanElement();
var span:SpanElement = new SpanElement();
                                   
spanBullet.text = "1."
span.text = "testing";
           
para.addChild(spanBullet);
para.addChild(span);

textFlow.addChild(para);

EditManager(textFlow.interactionManager).endCompositeOperation();

Thus does not work, I wonder if you can help me, thanks. Excuse my english, but i dont speek english,
TOPICS
Text layout framework
1.2K
Translate
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 ,
Jul 21, 2009 Jul 21, 2009

To create your own operation you should subclass FlowOperation.  Then write a doOperation undo and redo method.  When you actually want to execute the operation call EditManager.doOperation with an instance of your subclass.

In this case you don't need begin/endCompositeOperation.  Those methods are for combining multiple FlowOperations into a single operation.

Hope that helps,

Richard

Translate
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
New Here ,
Jul 22, 2009 Jul 22, 2009

Hi Richard,

Thanks for reply


But then I needed to run this code and it to be undone when I press Control + z, which not happen, because the method addChild not enter the queue of operations, thus firing an error.

It can not do a complex operation like this using only FlowOperation because I did not find methods to add DivElement, ParagraphElement, SpanElement with FlowOperation inside a TextFlow

I finded this class InsertTextOperation, and I tried to use it, but that does not allow me add a ParagraphElement or DivElement per exemple.

Just an observation, I think that addChild method does not fire FlowOperationEvent and therefore not enter the queue of operations.

Please help me.
Translate
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 ,
Jul 22, 2009 Jul 22, 2009

The closet thing to adding a paragraph is SplitParagraphOperation.  Do that at the end of a Paragraph.

Model changes (addChild/removeChild etc.) are not automatically recorded for undo.  Each operation is responsible for recording initial state to undo (and later redo) the change.

By the way more recent docs are available here:

http://livedocs.adobe.com/flex/gumbo/langref/

Richard

Translate
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
New Here ,
Jul 23, 2009 Jul 23, 2009

Hi, Richard

Thanks for reply,

So just to finish, can not put into the queue of undo and redo calling addChild and removeChild from TextFlow ?

Translate
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 ,
Jul 23, 2009 Jul 23, 2009
LATEST

Each operation manages undo/redo on its own.  None of the model changes are recorded for undo.

Richard

Translate
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