Re: Custom NSTextView for text annotations
Re: Custom NSTextView for text annotations
- Subject: Re: Custom NSTextView for text annotations
- From: Douglas Davidson <email@hidden>
- Date: Mon, 29 Mar 2010 11:22:58 -0700
On Mar 27, 2010, at 6:48 PM, Isaac Alston wrote:
> I am currently working on a document reader and annotation program.
> This program will allow the user to import text files and annotate
> them, both in the margins and by attaching annotations to specific
> words. As the cursor is hovered over a word, its annotation will
> appear in some sort of coloured 'bubble' beside it. I will have a
> custom file format to store the locations of these annotations in
> relation to the text file.
>
> I am fairly new to Cocoa and I am not sure about how to implement my
> annotations. I do not want to use PDF because most of the imported
> documents will only be in text format, for example works from Project
> Gutenberg. I have done some searching and the closest I have come to a
> solution is NSTextAttachment, but this inserts an object into the flow
> of the text and changes the line height of the text for example. I am
> thinking that I will have to somehow subclass NSTextView and do some
> custom drawing. Is this the right way to go about it? How should I
> write this feature? Any advice is much appreciated.
For starters, you could try out using NSToolTipAttributeName. That may not get you the appearance you want, though; if you want full control over the appearance, you will probably need to do some custom drawing of your own. If you look around, you can probably find some code that does things like drawing line numbers in the margins of a text view, which could give you a place to start from.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden