Re: Cocoa autoscroll question
Re: Cocoa autoscroll question
- Subject: Re: Cocoa autoscroll question
- From: Mark Dawson <email@hidden>
- Date: Tue, 1 Mar 2005 15:35:05 -0800
Yes, I had also just come to that conclusion, when I couldn't get the auto scrolling to happen, except when my cursor was over the scrollers, eventhough I called autoscroll earlier. I reread the docs again, I was being way too complicated (multiple calls, when only autoscroll was all I needed to call…)
So what does, "
Scrolls the receiver proportionally to <x-tad-bigger>theEvent</x-tad-bigger>’s distance outside of it" mean? Does that mean the further you drag past a scroller, the further the scroll or is it the faster the scroll?
Thanks!
mark
On Mar 1, 2005, at 2:23 PM, Jeremy French wrote:
I think you are starting from a different position, and consequently are repeating steps 1 thru 3 a second time.
For the sake of communication I'll refer to the NSView as MyView (per my example below). The idea of scrolling is that MyView's content area is larger than the actual area displayed in NSScrollView. Think of the NSScrollView as an area that can be moved up, down, left and right *over* the content area of MyView. Note that you don't actually see the entire size of MyView in Interface Builder, because MyView is contained within the smaller sized NSScrollView.
After you make MyView a subview of NSScrollView, the scrolling (by using the scrollbars) is automatic -- there is no additional programming.
When I said "in the 'mouseDown:' method implemented in MyView", I should have said "in the 'mouseDragged:' method implemented in MyView". In other words, add the line:
[[self superview[ autoscroll:event];
to your 'mouseDown:" method. When you drag beyond the content area displayed in the NSScrollView, the content area will automatically be scrolled.
I suggest you take a look at Chapters 14 and 15 in "Cocoa Programming for Mac OSX (second edition)" for additional details on this. I've found the book very helpful.
I've also emailed you -- separately -- a tiny project that illustrates just the scrolling.
---
On Mar 1, 2005, at 1:09 AM, Mark Dawson wrote:
I couldn't get this to work--maybe I'm misunderstanding something or am starting from a different position: I already have a view in my window that is a subview of a scroller (and I only want one scroller, I believe). Doing step #3 creates a 2nd scroller.
Also, if my present view is larger than the scroller (which is common, then this means that the "autoscrolling region" overlaps that view; is that desirable?
It almost seems like I should add a method to my existing -mouseDown routine that checks to see if the mouse is within a few pixels (or some distance) of the scroller, and if so, does the autoscroller calls.
Mark
TO SET UP THE "AUTOMATIC SCROLLING REGION"
----
Create a subclass of NSView, perhaps named "MyView". Import the class into Interface Builder, and then do the following:
1) Drag a "custom view" onto the window.
2) Select the "custom view", and change its class to MyView.
3) With the MyView instance selected, choose LAYOUT -> MAKE SUBVIEW OF - SCROLL VIEW.
4) Select the scroll view, and position accordingly. Also set its automatic resizing.
5) Double click on the NSScrollView until you select MyView.
6) Using the InfoPanel, make MyView's dimensions greater than the scroll view.
You should now be able to scroll MyView.
TO PROGRAM THE AUTO SCROLLING FUNCTIONALITY
---
In the "mouseDown:" method implemented in MyView, add the following line:
[[self superview] autoscroll:event];
where event is the NSEvent parameter passed to the mouseDown method.
SOME DOCUMENTATION
---
The book "Cocoa Programming for Mac OSX (second edition)" by Aaron Hillegrass has several chapters on this. See chapters 14 and 15.
---
On Feb 26, 2005, at 5:34 PM, Mark Dawson wrote:
I see that I can program NSView's autoscroll: to allow automatic scrolling when the user hits the "automatic scrolling region". However, I wasn't clear how to do that.
(1) How do I set up the "automatic scrolling region" and
(2) How do program the auto scrolling functionality?
I didn't see much documentation other than references that it could be done.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden