Forcing drawViewBackgroundInRect to display on text change...
Forcing drawViewBackgroundInRect to display on text change...
- Subject: Forcing drawViewBackgroundInRect to display on text change...
- From: Keith Blount <email@hidden>
- Date: Wed, 6 Apr 2005 10:25:50 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
I have an NSTextView subclass that uses
drawViewBackgroundInRect: to draw rectangles with
corners around ranges of text with certain attributes.
To do this, in my drawViewBackgroundInRect: override
method, I get the ranges I need to draw around, and
then get the rects for these ranges using
NSLayoutManager's rectArrayForCharacterRange:...
method. Then I go about merging these rects and
rounding the corners of the resulting shape - which
will obviously be an irregular shape if the range
stretches across several lines, with its start and end
part way through lines.
The trouble is, when I type before or inside these
ranges of text, the background drawing doesn't update
properly. The selection follows the text okay, but
when text drops off to the next line, the drawing at
the edges isn't updated - strange, as
drawViewBackgroundInRect does seem to get called. I
tried forcing drawViewBackgroundInRect to update [self
visibleRect] instead of just the passed-in rect, but
this made no difference.
The only way I have found to force the display to
update properly on edits is by overriding
didChangeText and calling [self setNeedsDisplay:YES],
but this seems rather brute force and not the optimal
way of doing things.
Does anybody have any idea about what could be going
on here?
Many thanks in advance,
Keith
__________________________________
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
http://www.advision.webevents.yahoo.com/emoticontest
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden