Skip navigation.
 
mlForcing drawViewBackgroundInRect to display on text change...
FROM : Keith Blount
DATE : Wed Apr 06 19:25:50 2005

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

Related mailsAuthorDate
mlForcing drawViewBackgroundInRect to display on text change... Keith Blount Apr 6, 19:25
mlRe: Forcing drawViewBackgroundInRect to display on text change... Douglas Davidson Apr 6, 21:49