Archive for December, 2010

TLF 1.0 Markup Specification


We now have a standalone specification of the Text Layout Framework markup for TLF 1.0 and TLF 1.1. This should be helpful to anyone who is trying to figure out what the XML format is for serializing and deserializing TLF text content.

TLF FlowElement LinkElement Events and EventMirrors

Examples are posted here:


TLF includes support for LinkElements. A LinkElement similar to an html <a> element can have a URL and respond to hover events and click events. The URL is invoked on click. The rendering of the LinkElement will change if a linkHoverFormat or linkActiveFormat is specified. This markup will turn the link red on hover and green on click:

<TextFlow version="2.0.0" xmlns="">
<p><a href="">
<linkActiveFormat><TextLayoutFormat color="0xff00"/></linkActiveFormat>
<linkHoverFormat><TextLayoutFormat color="0xff0000"/></linkHoverFormat>

LinkElements and event: syntax

LinkElements can also be used to generate events on the click that a client can intercept. This is done by specifying the LinkElement.href property as "event:eventName". Client code can then attach a listener to the textFlow for eventName.

In the examples zip demonstrates changing the color of the text when a link is clicked.

Note that if an EditManager is attached to the textFlow then LinkElements only respond if the CTRL key (on windows) or Command key (on Mac) is pressed.


Several TLF elements also support event mirrors. This allows a client to attach listeners directly to FlowElements for various events defined in the FlowElementMouseEvent class. These events events are generated by TLF by observing the MouseEvents that occur over the TextLines and mapped to the FlowElements. The events that can be listened for are defined in FlowElementMouseEvent. These events are: MOUSE_DOWN, MOUSE_UP, ROLL_OVER, ROLL_OUT and CLICK. Listeners are attached by calling getEventMirror on a FlowElement with support. getEventMirror returns an IEventDispatcher on which the listener can be attached. Only the following FlowElements support getEventMirror: LinkElement, TCYElement, SubParagraphGroupElement, SpanElement and InlineGraphicElement.

In the examples zip file demonstrates the use of event mirrors.

Note that getEventMirror is a tlf_internal function. Event mirror support is still experimental in TLF 2.0 though there are no known bugs with dispatching events. Less well tested is how event mirrors withstand editing operations as well as cut, copy and paste. Copy, for example will not have event mirrors on the new copy. Splitting a FlowElement will only preserve the mirrors on one of the elements. Unlike the event: syntax on LinkElements event mirrors are not imported and exported in XML.

For various reasons TLF does not use FTE eventMirrors. The main one is that an eventual goal of TLF is to permit data binding to a TextFlow so that a single TextFlow can be displayed in multiple views. This event mirror architecture is a necessary step in that direction.