Skip to main content
Inspiring
December 2, 2009
Question

Problems with EditManager.insertText() / EditManager.overwriteText()

  • December 2, 2009
  • 1 reply
  • 496 views

How have people implemented pasting into a TextFlow?

Ok, in a browser, you can rely on the usual behaviour of cut/copy/paste - but in AIR you need to define your own behaviour. (Unless someone knows how to invoke the usual behaviour without explicitly coding something?)

If I attempt to code the behaviour for paste, then I run into the limitation for EditManager.insertText() and EditManager.overwriteText() that they behavevery strangely with strings that contain newline characters.  When text alignment is set to TextFormatAlign.JUSTIFY, the final lines of paragraphs end up justified, and there is no way to correct the formatting of the text programatically.  (You can only correct it by retyping return characters into the text box.)

Does anyone know a workaround for this? - Or another way to implement paste that doesn't rely on the buggy EditManager.insertText() or EditManager.overwriteText() methods?

This topic has been closed for replies.

1 reply

Adobe Employee
December 2, 2009

Those methods insert exactly the characters you give them and are working as designed.  If you want special behavior for certain characters in the string then write some code so split the string at those characters and use different operations - like mapping newlines to splitParagraph.

Hope that helps,

Richard

Inspiring
December 3, 2009

I don't suppose there is a character code for splitParagraph?

Initially, I thought this was a problem with character codes 10 and 13 (different conventions on a Mac), and I was trying to use regular expressions to correct the problem.  If splitParagraph can be represented within the string, then it's easy to fix with regular expressions.

Otherwise, I need to write a loop to split the pasted text into the segments between newline characters.  Then perform an EditManager.insertText(), followed by EditManager.splitParagraph() for each segment (when the segment ends in newline).

If so, I still would have expected EditManager.insertText() / EditManager.overwriteText() to do this for me.  Because within a string, a newline IS a "splitParagraph".