Skip to main content
November 30, 2009
Question

overwriteText method in EditManager question

  • November 30, 2009
  • 1 reply
  • 607 views

I am selecting text with SelectRange() and then using the overwriteText method to replace the text. After this I reset the insert point using SelectRange() again and then call the damage method on the flowComposer and updateAllControllers. After all this the insert point is no longer flashing, but typing a character puts the character into the correct location and then the insert point starts flashing.

Is there something else I need to do to get the insertion point to show up after using overwriteText?

                    // It changed, so replace it!
                    var curSelectionState:SelectionState = compEditMgr.getSelectionState();
                    compEditMgr.selectRange(startWordPos, endWordPos-1);
                    compEditMgr.overwriteText(hyphenatedWord);
                    compEditMgr.selectRange(curSelectionState.absoluteStart + (hyphenatedWord.length - myWord.length), curSelectionState.absoluteStart + (hyphenatedWord.length - myWord.length));
                    textFlow1.flowComposer.damage(startWordPos, hyphenatedWord.length,flashx.textLayout.compose.FlowDamageType.INVALID);
                    textFlow1.flowComposer.updateAllControllers();

This topic has been closed for replies.

1 reply

Adobe Employee
November 30, 2009

After your final call to selectRange call refreshSelection.  Remove the call to damage and updateAllControllers.

The idea is that selectRange doesn't display the selection - that allows for multiple operations to be performed on different selections without the cost of drawing the selection.

Hope that helps,

Richard

November 30, 2009

Thanks. After making this change it still did not work, but I had the

code in a composeListener routine. I started a timer and did the

processing on the timer expiration and it all worked fine. What are the

rules on what you can do in a composeListener?

Adobe Employee
December 2, 2009

One thing you should not try to do in a compose listener is to change the text. This makes the text "dirty" (it's not longer composed up to date) and then it just needs to get composed all over again. Calling updateAllControllers or compose from within the compose listener will have no effect.