Reputation: 805
I'm hoping this will be a relatively easy thing to do.
I am writing a Mac app that will be (mostly) a giant NSTextView. I would like to override the default text position cursor to a unique color/shape cursor. I don't have a lot of Quartz or general drawing experience but that's something I can look into more on my own.
What I'm primarily looking for is advice on the best way to implement this. Is it going to be a matter of overriding the drawRect function, calling the super, and then implementing my own draw code?
How would I find the appropriate location to draw that cursor? Is it contained within the drawRect's passed rect?
Upvotes: 1
Views: 1601
Reputation: 11594
Essentially, you'll have to subclass the NSTextView and override some methods. The obvious one is
-(void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag
but that doesn't seem to entirely take care of it. Apparently, you also have to override a private method:
-(void)_drawInsertionPointInRect:(NSRect)arg1 color:(NSColor *)color
Look here for someone who's already trying to do this: http://www.cocoadev.com/index.pl?CustomInsertionPoint
Upvotes: 1