Re: Problem using NSView's scrollRect:by:
Re: Problem using NSView's scrollRect:by:
- Subject: Re: Problem using NSView's scrollRect:by:
- From: Quincey Morris <email@hidden>
- Date: Thu, 26 Jan 2017 10:43:02 -0800
- Feedback-id: 167118m:167118agrif8a:167118sSoNGoXtsO:SMTPCORP
On Jan 25, 2017, at 23:37 , Quincey Morris <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden