On Jan 25, 2017, at 22:59 , Tae Won Ha <taewon...@me.com> wrote:
> 
> I've read the documentation, but I thought that to "just" copy a potion of 
> the NSView's content to somewhere else inside the view, you don't have to do 
> the second and third part. And I did not quite understand the second part in 
> the doc.: what does it mean to change the origin of the view? Why do I "have 
> to" do it? Does it mean that scrollRect:by: only works if the view is somehow 
> embedded in a container view which "acts" like an NSScrollView?

Your “draw” method draws a red rectangle at the view origin (by default, at the 
top left of the view or the bottom left, depending on whether the coordinate 
system is flipped). That means, it’s always going to be drawn in the same 
place, from the user’s point of view.

What you want, presumably, is for the red rectangle to appear to move up or 
down when the view is scrolled. To get that effect, you must either draw it at 
a different place — at different view coordinates — or move the view origin to 
where you want the rectangle to draw.

There’s yet something else going on here, because you should at least see some 
of the red rectangle get redrawn in a different part of the view. Since the 
view doesn’t appear to change at all, that suggests:

— something is setting “needsDisplay” for the entire view, which causes your 
draw method to redraw the original view, wiping out the effect of the scroll 
method

— you might be using the scroll method to copy in the wrong direction, so that 
your copied bits are somewhere outside the visible portion of the view

You’re going to have to experiment to narrow down what’s wrong.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to