I'm changing the insertion point size by overriding -(void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag
, But it doesn't handle the first blink (when you move the insertion point, it goes back to normal)
I managed to handle the first blink by overriding the private method - (void)_drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor
.
But this is not a solution for me since overriding the private method will result in being decline by App Store. I want the app to be in App Store. I see Apps like iAWriter and Writeroom have a custom insertion point and they are in App store.
Does anyone know how they managed to do this, or a better way rather than overriding the private method?
Thanks.
- (void)_drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor
{
aRect.size.width = 3.0;
[aColor set];
[NSBezierPath fillRect:aRect];
}
- (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag
{
if(flag) {
aRect.size.width = 3.0;
[aColor set];
[NSBezierPath fillRect:aRect];
}
else {
[self setNeedsDisplayInRect:[self visibleRect] avoidAdditionalLayout:NO];
}
}
The problem is the clipping path that is in effect when drawInsertionPointInRect is called.
- (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag {
rect.size.width = 8.0;
NSBezierPath * path = [NSBezierPath bezierPathWithRect:rect];
[path setClip]; // recklessly set the clipping area (testing only!)
[path fill];
}
Note that the above code will leave artifacts (in my testing drawInsertionPointInRect is not called to clear the insertion point, only to draw it). Use setDrawsBackground:YES for a quick and dirty way to clear the artifacts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With