Re: Making a delegate NSResponder
Re: Making a delegate NSResponder
- Subject: Re: Making a delegate NSResponder
- From: "Louis C. Sacha" <email@hidden>
- Date: Sun, 28 Dec 2003 15:48:01 -0800
Hello...
I haven't been following this thread, so I'm not sure what you have
and haven't tried, but I have some random thoughts based on what was
in the quoted portions of your message...
1) Your noteFirstResponder: method fits the following prototype, right?
- (void)noteFirstResponder:(id)sender;
2) Have you tried naming the action method something else, like
dvNoteFirstResponder: just to make sure you aren't colliding with an
undocumented method with the same name somewhere in one of the
objects between the firstResponder and the class you expect to get
the call in?
3) Does the NSApplication method sendAction:to:from: return TRUE or
FALSE ? If it returns TRUE, that means that there is some object
somewhere responding to the action (just not the one you wanted). If
it is FALSE then NSApplication thinks no object in the responder
chain can handle that message.
4) It is possible that NSApplication uses the respondsToSelector:
method on each of the objects in the responder chain to determine if
they respond to the action message, not the two methods you mentioned
setting breakpoints on.
5) Have you tried providing an object (ie self) as the sender for the
from: argument? It's very unlikely, but possible, that something is
going wrong because that parameter is nil (which would probably be
considered a bug in NSApplication).
6) If the checkbox is a custom subclass that responds to
noteFirstResponder: then the superview (your delegating view) will
never get a chance to respond to the action message. The responder
chain moves up the view hierarchy (from each view to its superview,
and so on) so your delegating view has nothing to do with the action
unless all of the previous objects can not respond.
Hope something in there helps...
Louis
I made a sub-class of NSWindow called ResponderNotificationWindow. I
override makeFirstResponder: to call the super's implementation,
then it calls the window delegate's windowDidMakeFirstResponder:
method, and posts the corresponding notification.
So the responder chain ought to be complete. So why isn't my NSView
class picking up the action? Grrr.
On 23 Dec, 2003, at 8:59 AM, Fritz Anderson wrote:
I can't seem to find "windowDidMakeFirstResponder:" in any API or
reference I have handy. By any chance is it private? There may be a
reason it is private, namely that at the time it is called, the
responder chain may not be not complete.
This ain't Windows. The unpublished APIs aren't hidden gold.
-- F
On 22 Dec 2003, at 3:40 PM, Dustin Voss wrote:
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]
...
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.
_______________________________________________
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.
_______________________________________________
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.