Skip to main content
Known Participant
Jun 17, 2009 4:23 PM UTC
Question

Overwrite Text Functionality

Hi,

I would like to overwrite text in a textFlow with new text, keeping the currently selected format.

            IEditManager(_textFlow.interactionManager).setSelection(0,_textFlow.textLength);
            IEditManager(_textFlow.interactionManager).overwriteText(txt);

Sadly, however, the text gets inserted before the existing text, the "old" text is highlighted. Is there a different way? How can I replace the complete text of a textFlow?

I am using the original November built.

For any hint I'd be extremely greatful.

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

brian_thomas2
Adobe Employee
Adobe Employee
Jun 19, 2009 11:40 PM UTC

If EditManager.overwriteText() is not functioning correctly, this sounds like a bug. Have you tried this on our latest weekly builds?

http://labs.adobe.com/downloads/textlayout.html

Translate
A_Shiyaz
Known Participant
Aug 17, 2010 11:05 AM UTC

May be an old post, but useful to someone:

To overwrite use this:

var selState = new SelectionState(textFlow, 0, textFlow.interactionManager.absoluteEnd);
EditManager(textFlow.interactionManager).deleteText(selState);
EditManager(textFlow.interactionManager).overwriteText("abc", selState);

If you just want to append content, just use:


EditManager(textFlow.interactionManager).overwriteText("abc");

~ Shiyaz

[Edit]:

For some reason, the absoluteEnd gives -1 at times. However, we need the length of the text. Hence, use this:

var str = TextConverter.export(textFlow, TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;
var selState = new SelectionState(textFlow, 0, str.length);
EditManager(textFlow.interactionManager).deleteText(selState);
EditManager(textFlow.interactionManager).overwriteText("abc", selState);

~ Shiyaz

Message was edited by: A.Shiyaz

Translate
Aug 27, 2010 12:12 PM UTC

I don't think you go with that hack : delete and insert text, because in the future they might change something to one of the operation and it might break your code.

In their documentation for overwriteText, they give the following example

var textFlow:TextFlow = TextConverter.importToFlow( "How zzz brown cow.", TextConverter.PLAIN_TEXT_FORMAT );
textFlow.flowComposer = new StandardFlowComposer();
textFlow.flowComposer.addController( new ContainerController( this ));
var editManager:EditManager = new EditManager( new UndoManager() );
textFlow.interactionManager = editManager;
textFlow.flowComposer.updateAllControllers();

editManager.setSelection( 4, 6 );
editManager.overwriteText( "now" ); //Displays: How now brown cow.


I use 4.1 SDK and I there's no setSelection method. Instead I used selectRange, which take the same parameters as setSelection and the results are the way I expected.

Translate