• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextView overdraw bug in Leopard?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView overdraw bug in Leopard?


  • Subject: NSTextView overdraw bug in Leopard?
  • From: Martin Wierschin <email@hidden>
  • Date: Mon, 21 Jul 2008 16:10:09 -0700

Hi everyone,

We've had a report or two from users where text will incorrectly draw in an area it's not supposed to. Basically a line fragment (or part of one) from the prior NSTextContainer will draw over text in the current container. The odd part is that both line fragments are the last ones in each of their respective containers. In other words, the glyphs for the fragments are separated from each other by quite a bit of content.

It looks like this (hopefully the PNG comes through):

Attachment: Picture 1.png
Description: application/applefile

PNG image



Admittedly we have heavily customized the text layout system, but in the end it's just a series of non-overlapping text views. It could be our drawing code, which I've include below, but it hasn't given us problems before Leopard. We aren't using noncontiguous layout, but even so adding calls to ensureLayoutForTextContainer in drawRect doesn't fix the problem.

Has anyone else seen this before? Unfortunately we've been unable to reproduce the problem ourselves. We didn't receive any reports until after Leopard was released. Searching around the web there appear to be other Leopard related redraw issues, but I haven't seen anything about the Cocoa text system specifically.

Thanks for any help,

~Martin

PS: Our NSTextView subclass handles drawing like this:

- (void) drawRect:(NSRect)rect
{
if( rect.size.height <= 0 ) return;
NSLayoutManager* lm = [self layoutManager];
NSTextContainer* tc = [self textContainer];

NSPoint origin = [self textContainerOrigin];
NSRange glyphRng = (nil == tc) ? NSZeroRange : [lm glyphRangeForBoundingRect:rect inTextContainer:tc];

// background
[self drawViewBackgroundInRect:rect];
if( 0 != glyphRng.length ) [lm drawBackgroundForGlyphRange:glyphRng inTextContainer:tc atPoint:origin];
[lm drawSelectionForGlyphRange:glyphRng inTextContainer:tc atPoint:origin];

// text
if( 0 != glyphRng.length ) {
[NSBezierPath clipRect:rect]; // in case the glyphs being drawn are not entirely in the redraw rect
[lm drawGlyphsForGlyphRange:glyphRng atPoint:origin];
}
}


- (void) drawViewBackgroundInRect:(NSRect)rect
{
	if( [self drawsBackground] ) {
		[[self backgroundColor] set];
		[NSBezierPath fillRect:rect];
	}
}
_______________________________________________

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

  • Follow-Ups:
    • Re: NSTextView overdraw bug in Leopard?
      • From: Gerd Knops <email@hidden>
  • Prev by Date: set posterImage in QTKit?
  • Next by Date: Re: setFirstResponder to NSTextField fails 1st time, works next
  • Previous by thread: Re: set posterImage in QTKit?
  • Next by thread: Re: NSTextView overdraw bug in Leopard?
  • Index(es):
    • Date
    • Thread