discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSTextView and key events, WAS: [ 101845 ] Pageup Pagedn do not work


From: Alexander Malmberg
Subject: Re: NSTextView and key events, WAS: [ 101845 ] Pageup Pagedn do not work
Date: Mon, 31 Mar 2003 03:12:32 +0200

Willem Rein Oudshoorn wrote:
> 
> Sorry to keep bothering you all, but perhaps someone can enlighten me
> on some questions I have about the NSText system.
> 
> Consider the following diagram:
> 
> Picture
> -------
> 
>   superclass

Passing it to super effectively means sending it further down the
responder chain.

>      |
>      |
>   NSTextView ---> delegate
> 
> Question
> --------
> 
> Why is in -[NSTextView keyDown:]  the decission:
> 
> [non-editable] pass event to superclass, do NOT touch the
>                key down at all.

Non-editable text views don't handle key events, so it's just passed to
the next responder.

> [editable]     pass to delegate or handle in NSTextView, but
>                DO NOT PASS to superclass, even when the event
>                can not be handled by the NSTextView + delegate.

Where do you see this? When editable, the key event is passed to the
NSInputManager. All key events are swallowed by it, and the delegate
isn't involved. (The input manager will then parse the key events and
figure out what to do with them, and the delegate is involved when the
input manager passes this information back to the text view. See the
NSTextInput protocol.)

> Naive as I am, I would expect:
> 
> [non-editable]
> [editable]
>              *  Try to let the delegate handle the event
>              *  Try to handle the event ourself,
>              *  Send to superclass to continue traveling
>                 the NSResponder chain.

You can't both handle the key event (at least not using the input
manager) and pass it on. If the point is to get keyboard navigation in
text views, I think it would be better to have NSTextView handle key
events the normal way even when it is uneditable than to try to handle
it automagically somewhere else.

> Reason I ask:
> 
> * In the NSTextView documentation provided by Apple I do not
>   see any reference to special behaviour for non-editable
>   textviews with respect to the NSResponder chain.

This could be considered an implementation detail, though.

> * [the real reason]  If the situation is as I expect we can
>   quite easily implement pageup/pagedown for non-editable textviews.
>   Namely:
>   - Implement keyDown in NSScrollView (trivial and it works)

However, this is an even bigger deviation from OPENSTEP/OpenStep, and
potentially affects tons of things that use scroll views. Compared to
handling it in NSTextView, you'd also lose all text view specific key
handling, eg. selecting text with the keyboard.

>   - Applications that want to handle their own scrolling,
>     should register themself as delegate and handle the
>     textView:doCommandBySelector:

This method of overriding wouldn't work. By the time you get to
-textView:doCommandBySelector:, you must already have decided whether to
handle it or not.

- Alexander Malmberg




reply via email to

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