Skip to main content
August 5, 2009
Question

I need a Rich Text Editor so I'm making one but need help.

  • August 5, 2009
  • 1 reply
  • 596 views

Hi all,

I'm still figuring out the TLF and how it works so my question might seem dumb to some but any help would be great.

I'm making a RTE because I need access to a TextFlow when the user is done editing the text. It wasn't obviouse that the halo RTE could do that so I'm making my own.

The problem I'm running in to is that a user can select a range of text and apply something like italics to it. But if they don't have a range selected, say for example they just want to start off typing in italics, then how would I do that?

I've tried doing this and it works for a range but not anything else

var textfmt:TextLayoutFormat = rte.getFormatOfRange(null, rte.selectionAnchorPosition, rte.selectionActivePosition);
textfmt.fontStyle = (textfmt.fontStyle == FontPosture.ITALIC) ? FontPosture.NORMAL : FontPosture.ITALIC;
rte.setFormatOfRange(textfmt, rte.selectionAnchorPosition, rte.selectionActivePosition);

I also tried this when there wasn't a range selected and it also didn't work

var f:TextLayoutFormat = new TextLayoutFormat();
f.fontStyle = FontPosture.ITALIC;
IEditManager(rte.textFlow.interactionManager).applyContainerFormat(f);

Any help would be great.

Thanks.

This topic has been closed for replies.

1 reply

August 5, 2009

Never mind, I did the following and things worked for me.

if (rte.textFlow && rte.textFlow.interactionManager is IEditManager)
{
           var f:TextLayoutFormat = new TextLayoutFormat();
           f.fontStyle = (italics.selected) ? FontPosture.ITALIC : FontPosture.NORMAL;
           IEditManager(rte.textFlow.interactionManager).applyFormat(f, null, f, null);                       
}  

If you want to add anything or explain anything I would appreciate that.