NSScrollView bug or misunderstood behavior?
NSScrollView bug or misunderstood behavior?
- Subject: NSScrollView bug or misunderstood behavior?
- From: Ivan Kourtev <email@hidden>
- Date: Sat, 11 Nov 2006 13:17:09 -0500
I have an app with a custom document view enclosed in a scroll view.
I need certain objects to be drawn in the background (behind all
other objects) in the custom view and always at the same position
relative to the visible rect of the custom view. By "same position"
I mean that when the user scrolls the document view, these particular
objects do not move (only the document content moves and is redrawn).
I experimented with several solutions and am currently trying to do
it like this - subclass NSScrollView and do my own drawing in the
subclassed scroll view:
- (void)drawRect:(NSRect)rect {
[super drawRect:rect];
// My drawing here
}
Weirdness #1: In order to see the drawing, I had to deselect "Draws
background" for the scroll view in IB -- just sending [self
setDrawsBackground:NO] to my subclassed scrolled view didn't work.
Can anyone explain why is this happening? I understand that there is
setDrawsBackground for the clip view of the scroll view as well but I
can't fully understand the interaction and behavior. Does the
drawsBackground of the scroll view actually control the background
drawing of the clip view (that's my guess)?
Weirdness #2: Because of what is done in 1 above (and according to
the docs), the clip view is now set to NOT copy on scroll. So my
custom document view is getting its entire visible rectangle
invalidated and drawing performance is slowing down in drawRect. I
tried to get around that by sending setCopiesOnScroll:YES to the clip
view (drawing performance issue fixed since invalidated rectangles on
scroll are much smaller now) but now scrolling also moves the content
drawn using the drawRect of the subclassed NSScrollView? That's
contrary to my expectations -- can anyone provide an explanation of
this behavior?
The best explanation that I can come up with is that drawing in the
views is not buffered -- so when clip view copies on scroll it
doesn't just copy the drawing in the custom view but the drawing in
the screen rectangle composited by drawing in the scroll view, clip
view, custom view's, etc. Can someone confirm this?
Thanks much for any help.
--
ivan
_______________________________________________
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