Sunday, March 28, 2010

Creating a RTE with Spark TextArea +...

I'm trying to build a rich text editor with the TLF/FTE apis as well as using the Spark TextArea component found in the latest Flex 4 SDK.

I need to apply formatting to a selected range of text and/or start a new 'format group' (so to speak) so the user will begin typing in the format that he/she has chosen. I'm able to get selected indexes of the text via TextArea.selectionActivePosition and TextArea.selectionAnchorPosition, but how do I migrate this information to use it with the TextFlow object?

In the old pre FP10 api, you can just apply a TextFormat using the TextField.setTextFormat method and apply the default text format by setting the TextField.defaultTextFormat property. Is there a way to accomplish similar functionality in TLF/FTE?

Here are a few usage scenarios:

1. A user selects a range of text in the TextArea and uses a ComboBox to set the font of the selected text. The selected text has the new font applied to it.

2. A user puts his text caret in the middle of some text and clicks a button to insert an image into the TextArea.

I guess it all comes back to not understanding how to convert/apply TextArea.selectionAnchorPosition/TextArea.selectionActivePosition to a TextFlow object. Can anyone help me?

Creating a RTE with Spark TextArea +...

To format the selection, use setFormatOfRange(). To learn about the formatting of the selection, use getFormatOfRange(). To get the TextFlow, use the 'textFlow' property. If you don't see these APIs on the Spark TextArea, get a newer build of the Flex 4 SDK.

Gordon Smith

Adobe Flex SDK Team

Creating a RTE with Spark TextArea +...

Gordon, thanks. I think this will help me get going in the right direction

-TK

No comments:

Post a Comment