NSScrollView bug(s)?
NSScrollView bug(s)?
- Subject: NSScrollView bug(s)?
- From: Tobias Hermann <email@hidden>
- Date: Thu, 13 Mar 2003 13:56:24 +0100
Hi!
Some important infos:
Mac OS 10.2.4
DevTools December 2002
I am implementing a small control by subclassing NSControl.
That control draws itself within the drawRect: method.
In interface builder, I simply add a custom view and set the custom
class to my class name (MyControl).
All that works fine.
I somewhat optimized the drawing stuff within the drawRect: method so
that only the neccessary stuff gets painted (that lies within the
passed rect).
I am sending displayRect: messages to my control with optimized
rectangles in order to only draw the changes I made and not to redraw
the whole thing.
All the drawing routines (e.g. from NSBezierPath) don't draw outside
that rect, because it seems that the clipping area is set properly.
Then I wanted to make the thing more flexible. The control might get
very huge, and so I decided to wrap it into a NSScrollView.
(Interface Builder -> Layout Menu, Make SubView of -> Scroll View).
Now comes the first strange behavior (if you are too lazy to read, pse
read the second "bug" first, that is more important to me :-)) :
The MyControl now lies within the NSScrollView.
The drawRect: method of MyControl still gets called with my optimized
rectangles, but the clipping area is gone. My drawing stuff (with
NSBezierPath for example) now draw not only within that passed rect,
they draw everywhere within the visible view. I don't know why.
I am currently using the following workaround, but I want to know if
that is a bug, or am I doing/understanding somthing wrong ?!
Here the workaround: (a snippet of my drawRect: method of MyControl
class)
- (void)drawRect:(NSRect)rect {
// don't know why this is needed, but as I put this control into a
scrollview, everything gets drawn everytime,
// not only the stuff within rect !! not using it in a scroll view
would make it without that code!
NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];
[NSBezierPath clipRect: rect]; // manually set the clipping area
// here is my drawing stuff...
// ...
[context restoreGraphicsState]; // kick away the clipping area
}
Any ideas?
------------------------------------------------------
Here is the second strange behavior (possibly a bug?):
------------------------------------------------------
The following problem only appears on brushed metal surfaced windows!
I still have put the MyControl instance into a NSScrollView. Everything
works fine, instead of one thing under one circumstance:
The MyControl instance is bigger than the NSScroll-ClipView (so the
scrollbars get active). The scrollbars are scrolled to the leftmost and
lowest position. Usually you can grab a brushed metal window (if it is
enabled) everywhere where there is no control and move it over the
screen.
In that constellation, you can NOT grab it on the right side and on the
upper side besides the NSScrollView (but you can do it on the left and
lower side besides it). If you now scroll to the rightmost and
uppermost position of the ScrollView, you still cannot grab the window
at the mentioned positions. If you now RESIZE the window only a little
bit (just a pixel or so is enough), everything is fine, you can grab it
and move it. If you now scroll back a bit with the ScrollBars of the
NSScrollView, the strange behavior starts again until you repeat these
steps.
It seems that the window thinks that the documentView really IS there
(although the clipView shows only a part of it). But MyControl is not
receiving any mouseEvents either.
And due to that behavior stops when resizing the window and starts
again when "moving some documentView outside the clipView", I think
that this might be a bug (I can find no sense here!).
Wow! That was not easy to describe! Please let me know if you
understood what I said :-) And sorry for my English :-)
best regards!
Tobi
_______________________________________________
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.