FROM : Douglas Davidson
DATE : Mon Apr 04 17:43:57 2005
On Apr 2, 2005, at 12:35 PM, Satoshi Matsumoto wrote:
> on 05.4.3 1:59 AM, Roland Silver at <email_removed> wrote:
>
>> I have a simple Cocoa application with a controller and a window with
>> an NSTextView. I want to intercept keydown events on their way to the
>> text view, process them with a function or method, and send a
>> possibly
>> different keydown event on to the text view.
>> Nothing I try works.
>> Any suggestions?
>>
>
> Subclass NSTextView and override following method.
>
> - (void)keyDown:(NSEvent *)theEvent
>
I want to again recommend against subclassing NSTextView and
overriding keyDown: except in extreme circumstances. In most cases
it is better to act as the text view's delegate and handle
textView:doCommandBySelector:,
textView:shouldChangeTextInRange:replacementString:,
textView:willChangeSelectionFromCharacterRange:toCharacterRange:, and
so forth. You should override keyDown: if you want to handle raw key
presses before any input methods or key bindings have been applied;
if you do not want that, then you should avoid overriding keyDown:.
Douglas Davidson
DATE : Mon Apr 04 17:43:57 2005
On Apr 2, 2005, at 12:35 PM, Satoshi Matsumoto wrote:
> on 05.4.3 1:59 AM, Roland Silver at <email_removed> wrote:
>
>> I have a simple Cocoa application with a controller and a window with
>> an NSTextView. I want to intercept keydown events on their way to the
>> text view, process them with a function or method, and send a
>> possibly
>> different keydown event on to the text view.
>> Nothing I try works.
>> Any suggestions?
>>
>
> Subclass NSTextView and override following method.
>
> - (void)keyDown:(NSEvent *)theEvent
>
I want to again recommend against subclassing NSTextView and
overriding keyDown: except in extreme circumstances. In most cases
it is better to act as the text view's delegate and handle
textView:doCommandBySelector:,
textView:shouldChangeTextInRange:replacementString:,
textView:willChangeSelectionFromCharacterRange:toCharacterRange:, and
so forth. You should override keyDown: if you want to handle raw key
presses before any input methods or key bindings have been applied;
if you do not want that, then you should avoid overriding keyDown:.
Douglas Davidson
| Related mails | Author | Date |
|---|---|---|
| Roland Silver | Apr 2, 18:59 | |
| Bryan Zarnett | Apr 2, 19:13 | |
| Satoshi Matsumoto | Apr 2, 22:35 | |
| Roland Silver | Apr 3, 02:36 | |
| Roland Silver | Apr 3, 02:42 | |
| James Spencer | Apr 3, 06:43 | |
| Bryan Zarnett | Apr 3, 09:38 | |
| Bryan Zarnett | Apr 3, 10:07 | |
| Satoshi Matsumoto | Apr 3, 13:54 | |
| Douglas Davidson | Apr 4, 17:43 |






Cocoa mail archive

