• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Intercepting Some Keyboard Events for NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Intercepting Some Keyboard Events for NSTextView


  • Subject: Re: Intercepting Some Keyboard Events for NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 15 Jul 2002 10:48:20 -0700

On Monday, July 15, 2002, at 10:26 AM, John Nairn wrote:

I will try the NSApp method, although I also found another solution.

Although I could not create a custom class for NSTextView in Interface Builder, I found an example in "Cocoa Programming for Mac OS X (Hillegass) of subclassing NSTextView when the nib file opens. It has some nice features such as I can override commands (which after some testing) worked with

- (void)cancel:(id)sender
- (void)insertNewline:(id)sender

and so on. I can also insert a keyDown method here and act on keys or pass on to super if needed. I can do all I need, but will this have the same problems you mentioned below (i.e. swallowing something the input manager wants)?

Finally, if subclassing NSTextView is a good idea, how come it can not be done in Interface Builder?

Subclassing NSTextView is good and necessary for certain things, but it should not be your first resort; delegation should be considered first and used where appropriate. Subclassing NSTextView is certainly possible in Interface Builder, although it is not as easy as it could be; this is not deliberate, it arose from some limitations in the AppKit.

If you do end up subclassing NSTextView, overriding insertNewline:, cancel:, etc. is fine. The dangerous one is keyDown:, which unfortunately people tend to want to override first. You can look in the mailing list archives for my previous posts on this topic, which describe the path that key events take in the text system.

Douglas Davidson
_______________________________________________
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.

References: 
 >Re: Intercepting Some Keyboard Events for NSTextView (From: John Nairn <email@hidden>)

  • Prev by Date: Re: Intercepting Some Keyboard Events for NSTextView
  • Next by Date: Re: Multiples NSDocumentController's ?
  • Previous by thread: Re: Intercepting Some Keyboard Events for NSTextView
  • Next by thread: rotate a bezierpath
  • Index(es):
    • Date
    • Thread