LayoutManagerDemo

Last Revision:
Version 1.2, 2012-06-07
Upgraded to Xcode 4.3 and Mac OS X 10.7
(Full Revision History)
Build Requirements:
Xcode 4.3, Mac OS X 10.7.x or later.
Runtime Requirements:
Mac OS X 10.6.x Snow Leopard or later

This application demonstrates interrogating the layout manager for information about text layout, and the use of temporary attributes to color text. Specifically, we provide rollover coloring of text--one color for the line, another for the word, and a third for the character under the mouse. A subclass of NSTextView is used, but solely for the purpose of obtaining mouse events. The interesting portion of the code involves the conversion of mouse coordinates to a particular glyph and character index, then determining the corresponding line and word, and finally using temporary attributes for coloring.