Skip to main content
Participating Frequently
August 6, 2010
Question

textFlow.flowComposer.lines

  • August 6, 2010
  • 1 reply
  • 974 views

Hi,

I have created a custom highligter class since the EditManager applyFormat is too slow for lots of text and lots of highlights. Everything works great for RichEditableText - The textFlow's flowComposer's lines array contains a listing of TextFlowLines and from there I can determine which ones are visible on the screen or in the viewport, and then from there figure out where the characters (atoms) positioning information is from the TextLine/TextBlock methods.

However, RichEditableText does not support truncation. So I tried RichText, but the textFlow/flowComposer/SpanElement/ParagraphElement are no help. None of the information about the lines is in the rich text with truncation.

What do I do?

I tried going to the source of RichEditableText, but I can't find where the lines of the textFlow get populated in the flowComposer's lines array. The only explination I have for that is that the source in the premium build that I have doesn't match up with the binary - VERY annoying.

Any help?

This topic has been closed for replies.

1 reply

Adobe Employee
August 6, 2010

Look again.  In 1.1 the TextFlowLine is added in FlowComposerBase.as function addLine around line 441.

As discussed earlier directly accessing the textFlow.interactionManager and calling applyFormat in a loop like this will work void the performance issue with applyFormat.  This assumes the text is being edited and there is an interactionManager attached to the TextFlow.

                var rtxt:RichEditableText;
               
                var em:EditManager = rtxt.textFlow.interactionManager as EditManager;
                em.beginCompositeOperation();
                while (stufftodo)
                {
                    var state:SelectionState = new SelectionState(rtxt.textFlow, startPosition,endPosition);
                    em.applyFormat(newattrs,newCharacterAttributes);
                }
                em.endCompositeOperation();

However we don't support truncation when the text is being edited.  Truncation is only available when the text is being displayed initially and before editing begins.  In that case we're using a faster composer that doesn't maintain an array of TextFlowLines.

Good luck with your custom highlighter class.

Richard

Ir0nCladAuthor
Participating Frequently
August 7, 2010

Thanks for your response Richard,

Right, I've seen add line. My problem with discovering how rich text does its thing is a difference between the compiled framework code and the version of the source that comes with the permium copy of flashbuilder - they are out of sync.

Regardless, what I really want is to be able to get character position information and what line a character is on WITHOUT using textFlow.

Using TextFlow and the FlowComposer is only populated in ONE circumstance, and that is with RichEditableText when it is selectable at a minimum, but with no constraints, such as left, top, right, etc...

How else can we get that information? The TLF framework seems pretty static and non-extensible/decoratable if we can't get basic information about the atoms without special circumstances.

Thanks for any information you can give.

Adobe Employee
August 10, 2010

What you're looking for is tricky. The reason the simpler text factory code is used for the start is that its very lightweight. Once the text is selectable, we need to keep more information so its easy to make a mapping from the TextLines back to the original text and vice versa. That's one of the things that the TextFlow and the ContainerController is doing for you. So the easiest way to get what you want is to (temporarily) set the selection on the TextContainerManager. Get the interactionManager and call selectRange(0, 0), and then undo it by calling selectRange(-1, -1). Now you have a TextFlow and an interactionManager and you can use the functionality in the SelectionManager to do hit testing. I'm not sure if that's what you were looking for though.

- robin