Skip to main content
January 28, 2009
Answered

Several questions on TLF

  • January 28, 2009
  • 1 reply
  • 540 views
Question 1: Is it possible to tell EditManager to do something on Enter key event and do not move text caret to the lower line in the same time?

Question 2: Is it possible to tell EditManager to limit user input to some amount of characters, some thing similar to maxChars of the TextField?

Question 3: How to get text represented by the TextFlow in XML format with extra spaces?

For example: I write "Hello world" and then select world "Hello" and change its colour to blue. If I make text export form the TextFlow in XML format I get following:

<flow:TextFlow whiteSpaceCollapse="preserve" xmlns:flow=" http://ns.adobe.com/textLayout/2008">
<flow:p direction="rtl" marginLeft="2" marginRight="3" marginTop="5">
<flow:span color="0x6699">Hello</flow:span>
<flow:span>world</flow:span>
</flow:p>
</flow:TextFlow>

Which have no space before the word "world", as it should be (but in the same time I see on my screen that the space actually appears in the edit box between words "Hello" and "world" after I changed colour).
I use following operation to export:

XML.ignoreWhitespace = false;
var textXML:XML = new XML(TextFilter.export(tf, TextFilter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE));

Where "tf" is a variable that contains my TextFlow instance.
This topic has been closed for replies.
Correct answer robin_briggs
Here's a couple of quick pointers:

(1) See Configuration.manageEnterKey. You pass a Configuration object in when you create a new TextFlow. If the Configuration you pass in (or the defaultConfiguration if you don't specify one) has manageEnterKey set to false, then TLF will not handle the enter key. You can then attach your own event listener and handle it how you want.

(2) Yes, but I think you may need to get the more recent version of TLF in the Gumbo release for this to work. Basically you will need to attach to the FlowOperationEnd event, and remove whatever extra characters got inserted or pasted. Whatever you call in the EditManager from the FlowOperationEnd event handler will be undone together with the original operation as a single atomic transaction.

(3) This is not a complete answer, but a few hints of what to look for: When you convert from XML to a String, you need to be careful that XML.prettyPrint is turned off, or it will insert extra whitespace. Also ignoreWhiteSpace needs to be set to false, since that will cause leading and trailing spaces to be removed from spans. Check those two things first.

Hope this helps!

1 reply

robin_briggsCorrect answer
Adobe Employee
January 28, 2009
Here's a couple of quick pointers:

(1) See Configuration.manageEnterKey. You pass a Configuration object in when you create a new TextFlow. If the Configuration you pass in (or the defaultConfiguration if you don't specify one) has manageEnterKey set to false, then TLF will not handle the enter key. You can then attach your own event listener and handle it how you want.

(2) Yes, but I think you may need to get the more recent version of TLF in the Gumbo release for this to work. Basically you will need to attach to the FlowOperationEnd event, and remove whatever extra characters got inserted or pasted. Whatever you call in the EditManager from the FlowOperationEnd event handler will be undone together with the original operation as a single atomic transaction.

(3) This is not a complete answer, but a few hints of what to look for: When you convert from XML to a String, you need to be careful that XML.prettyPrint is turned off, or it will insert extra whitespace. Also ignoreWhiteSpace needs to be set to false, since that will cause leading and trailing spaces to be removed from spans. Check those two things first.

Hope this helps!