NSTextView insertion point doesn't reflect paragraphSpacingBefore
NSTextView insertion point doesn't reflect paragraphSpacingBefore
- Subject: NSTextView insertion point doesn't reflect paragraphSpacingBefore
- From: Aram Greenman <email@hidden>
- Date: Fri, 13 Feb 2004 11:54:09 -0800
The insertion point in an NSTextView doesn't reflect the
-[NSParagraphStyle paragraphSpacingBefore] if it is at the end of the
text and the current paragraph is empty. I've reported this, but in the
meantime I'm trying to work around it by overriding -[NSTextView
drawInsertionPointInRect:color:turnedOn:] to move to the correct rect.
The problem is it doesn't work until the second "blink".
- (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color
turnedOn:(BOOL)turnedOn {
unsigned insertion = [self selectedRange].location;
if ((insertion == [[self string] length] && // at end of text
insertion == [[self string]
paragraphRangeForRange:NSMakeRange(insertion, 0)].location) && // at
start of paragraph
insertion != [[self layoutManager]
characterRangeForGlyphRange:[[self layoutManager]
glyphRangeForTextContainer:[self textContainer]]
actualGlyphRange:NULL].location) { // not the first paragraph in this
text container
rect.origin.y += [[[self typingAttributes]
objectForKey:NSParagraphStyleAttributeName] paragraphSpacingBefore]; //
move the insertion point
}
// call super with corrected rect
[super drawInsertionPointInRect:rect color:color turnedOn:turnedOn];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.