[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView+NSScrollView patches

From: Wolfgang Lux
Subject: NSTextView+NSScrollView patches
Date: Wed, 28 Feb 2007 16:55:59 +0100

Hello list!

Attached is a small patch for the NSTextView and NSScrollView classes.
The NSTextView patch replaces the -scroll{Line,Page}{Up,Down}: methods
by a working implementation. The method invocations are simply forwarded
to the enclosing scroll view (if any). The NSScrollView patch implements
-scrollLine{Up,Down}: (essentially copied from -scrollPage{Up,Down}:) and
makes a scroll view interpret (page) up/down function keys. That way you
can now scroll read-only text views with the cursor keys mostly similar
to Mac OS X (*). A nice side effect is that you now can use the page up
and down keys in other places, e.g., the file browsers of the open and
save dialogs.

Finally, the patch also changes the default key bindings along the lines
used on Mac OS X, i.e., page up and down keys invoke -scrollPageUp:
and -scrollPageDown: rather than -pageUp: and -pageDown: (ditto for
control-up and control-down). The old page up and page down are still
there but require pressing control or alternate in addition to page
up and down. Note the subtle difference between -pageUp: and - scrollPageUp:.
The former changes the current selection so that it is in the visible
range after scrolling, whereas for the latter the selection remains
unchanged. I clearly prefer the latter behavior as default for the
page up and down keys, but this is certainly a matter of taste.


(*) It looks like Cocoa text views always invoke -interpretKeyEvents:
from their -keyDown: method instead of forwarding the call to the super
class if the text view is not editable. The advantage of that is that
the cursor keys used with modifier keys behave consistently for editable
and read-only text views (which they don't with my patch). However, I am
not sure whether all NSTextView actions are really prepared to do something
useful (i.e., nothing) for read-only text views, so I refrained from
changing NSTextView's -keyDown: method.

Attachment: gui.patch
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]