On Jan 25, 2017, at 23:37 , Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:
> 
> There’s yet something else going on here

I tried creating a project with your code, and there is indeed something else 
going on here:

1. In a default, non-storyboard, non-document macOS application created in 
Xcode 8.2.1, the main window’s content view (the parent of your 
programmatically created view) has “wantsLayer” turned on. You can see this in 
the “View Effects” inspector (the rightmost inspector tab in IB). This is 
enough to prevent the scroll method from doing what you expect.

2. When I turned this off, the scroll method call (in the action method) was 
not enough to trigger redrawing of the view, so nothing happened immediately. 
However, as soon as something happened to trigger a view update, the moved 
image appeared.

3. It still did not work exactly right, because the window has rounded corners 
at the bottom left and right, and the bottom left of the red rectangle was 
clipped away by the round corner. When copied by the scroll method, the 
“missing” piece of the red rect was filled in with another color.

So:

— you are going to have to turn off Core Animation for your view hierarchy

and then you are going to have to do all 3 things that it says to do in the 
documentation:

— scroll to move pixels

— origin change so that your draw method re-draws the rest of the revealed 
content in the correct, “scrolled” place

— a call to the setNeedsDisplayInRect method to trigger a view draw/update cycle

plus:

— careful calculation of which pixels are actually moved, in case the visible 
area of your view is not the simple rect that you expect it to be


_______________________________________________

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