Re: Line/page scrolling an NSScrollView
Re: Line/page scrolling an NSScrollView
- Subject: Re: Line/page scrolling an NSScrollView
- From: Allan Odgaard <email@hidden>
- Date: Sat, 10 Apr 2004 18:12:32 +0200
On 10. Apr 2004, at 12:45, Glen Low wrote:
I'm racking my brains (and the docs) for this one in case I missed
something obvious. If I have an NSScrollView how do I either (a)
programmatically scroll it by exactly one line or one page or (b) make
it respond to the usual keystroke e.g. page down to scroll by exactly
one line or one page?
You'll need to implement the moveUp:/moveDown: action methods in the
embedded view and have these use scrollRectToVisible: or
scrollToPoint:.
As far as page up/down go, it seems to respond to the pageUp or
pageDown method, but no such luck with line up/down.
I am also slightly confused about how things are supposed to work. It
seems the scroll view implements pageUp: and pageDown:, but my default
key bindings has the page up/down keys set to send scrollPageUp: and
scrollPageDown:.
According to
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
BasicEventHandling/Concepts/KeyEvents.html>
If you implement keyDown: [...] but do not implement the
scrollPageDown: action method, the document view will
still be scrolled within the scroll view when the user
presses the Page Down key [...]. The NSScrollView class
provides a default implementation [...]
Another place in the documentation (or an older revision?) I am quite
sure it explicitly stated that *only* the page up/down was handled by
the scroll view, and the rest had to be handled by the embedded view.
I have not looked fully into this, so I might be wrong about which of
the methods the scroll view implements -- I have changed my user key
bindings to send pageUp: and pageDown: for the page up/down keys, and
haven't had problems (i.e. the scroll view *does* react on these), in
fact there is the added benefit that the caret will move in text fields
(which was the real reason behind my change).
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.