Saturday, April 14, 2007

NSTextView transformations

Ever needed a transformed (e.g. rotated) Text editing? Ever wondered why most Cocoa applications do not support transformed text editing?

Remember that as a subclass of NSView, NSTextView inherits its -setFrameRotation: accessor method from NSView.

First of all I miss a -setFrameTransform: method, that would allow free transformation to be applied to instances of NSView. But there is the rotation feature only for now.
But even this is not working correctly.

As text caret (the text cursor) and red markers for misspelled words are drawn in base coo system (the coo system of the window the view belongs to) the rotated results are quite funny:
All the text is formatted and drawn correctly. Even the selected and marked text ranges are drawn correctly. But blinking text caret and misspelled words markers get drawn unrotated.

So right now transformed text editing is impossible to achieve without writing your own text editor.

No comments: