Re: need advice on subclassing NSScrollVIew
Re: need advice on subclassing NSScrollVIew
- Subject: Re: need advice on subclassing NSScrollVIew
- From: Benjamin Stiglitz <email@hidden>
- Date: Fri, 20 Mar 2009 14:50:06 -0400
- Mail-followup-to: email@hidden
> In a similar situation, I didn't subclass NSScrollView. I subclassed NSView and inserted an NSScroller directly as its subview. I tracked the position with a 64-bit variable which I converted to a range suitable for the NSScroller just for setting its thumb position and size. I set my view as the NSScroller's target to convert back to my 64-bit position.
>
> In the subclass' -drawRect: method, I calculated the visible portion of the view, and simply drew that - no NSClipView required. For your case, you'd have an additional step involving the scale; be careful with loss of precision there.
>
> Despite being somewhat more work to implement, this proved to be more efficient and also a good learning experience regarding the view drawing mechanism.
One unfortunate caveat of this solution is that it’s very difficult to
exactly reproduce some of the behavior of NSScrollView, especially if
you plan to handle dragging or anything else that requires
-autoscroll:ing.
And don’t forget about exposing the proper accessibility roles and
attributes.
-Ben
_______________________________________________
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