• 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
Making a delegate NSResponder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making a delegate NSResponder


  • Subject: Making a delegate NSResponder
  • From: Dustin Voss <email@hidden>
  • Date: Mon, 22 Dec 2003 13:40:08 -0800

I'm having trouble with my application. Basically, my implementations of tryToPerform:with: and doCommandBySelector: in an NSView sub-class aren't being called as part of the responder chain in the way I expect.

I'm working on an app with a main window that shows documents in sub-views. The sub-views are instances of an NSView sub-class I wrote called DelegatingView. The DelegatingView class is a view that has a delegate. It is supposed to give the delegate a chance to handle any action messages and commands that it receives.

To do this, I have overridden NSView's tryToPerform:with: and doCommandBySelector:. They call the selector on the delegate if it implements it, or else they call super for normal handling. I also overrode acceptsFirstResponder to return YES.

I'm expecting the DelegatingView class to handle an action I wrote called "noteFirstResponder:" which I send to the first responder when it changes. I send it from the window controller's windowDidMakeFirstResponder: method like so:
[NSApp sendAction:@selector(noteFirstResponder:) to:nil from:nil]

The action ought to get passed up the responder chain from the first responder. The first responder is in a DelegatingView, so the DelegatingView should get this action and pass it to its delegate. The delegate (a view controller) will then know that its DelegatingView contains the first responder.

In my tests, the first responder is a checkbox within a DelegatingView. I make the checkbox the first responder by tabbing to it. The checkbox gets a focus ring, and windowDidMakeFirstResponder: is called, so the checkbox should be the first responder and should get the "noteFirstResponder:" action.

However, I can't trace execution past the sendAction:to:from: call. I put breakpoints on the DelegatingView's tryToPerform:with: and doCommandBySelector: methods, but they never get hit. This would seem to mean that the DelegatingView is not actually part of the responder chain, or else noteFirstResponder: does not get passed along the responder chain, both of which seem very unlikely.

I must be overlooking something, because this seems like it should work. What am I missing?

Thanks in advance for any help!

--
Dustin
_______________________________________________
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.

  • Follow-Ups:
    • Re: Making a delegate NSResponder
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: what happpens after closing NSOpenPanel?
  • Next by Date: Re: Saving information to a file
  • Previous by thread: Re: NSTableView background
  • Next by thread: Re: Making a delegate NSResponder
  • Index(es):
    • Date
    • Thread