I’m changing the caret size using - (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag. Anyway, when I move selection, the caret momentarily changes back to its default size.
Is there another method that draws the caret that I need to override?
What I’m currently doing:
- (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag {
aRect.origin.y -= 1;
aRect.origin.x -= 1;
aRect.size.width += 1;
aRect.size.height += 1;
[super drawInsertionPointInRect:aRect color:aColor turnedOn:flag];
}
Original Answer:
If you’re not doing it already, subclass
NSTextViewand then implement thedrawInsertionPointInRect:color:turnedOn:method yourself to do the fancy caret drawing yourself.Also pay attention to this line from the documentation:
Subclassing is the way to go.
More application-specific answer:
Instead of calling into
[super drawInsertionPointInRect..., consider doing all the drawing yourself.Something like this:
(the code for which I stole from here)