• 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
SOLVED Re: Windows and Default Notification Center
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SOLVED Re: Windows and Default Notification Center


  • Subject: SOLVED Re: Windows and Default Notification Center
  • From: Bruce Truax <email@hidden>
  • Date: Fri, 23 Jul 2004 22:01:07 -0400

Thank you Fritz and Public Look. Fritz, your little tutorial on the
responder chain and the correct function to use made all the difference. I
have added that to my dialog boxes and now they all work properly.

Bruce Truax

On 7/23/04 3:01 PM, "Fritz Anderson" <email@hidden> eloquently
wrote:

> First, are you sure your window controller is in the responder chain?
> Particularly, is it its window's delegate?
>
> Second, NSApplication doesn't respond to respondsToSelector: any
> differently than any other class. If NSApplication (or an ancestor
> class) doesn't implement the message, it returns NO. This means that it
> will return NO virtually always in the code sample you provide, even
> for action messages that the responder chain really does handle.
>
> Third, the test you mean to make is whether targetForAction: returns
> nil. But the test is unnecessary, as there's no harm (other than a
> beep) in sending an action that the responder chain doesn't handle.
>
> Fourth, if you want to send an action message up the responder chain
> starting at the first responder, the message to use is
> [NSApp sendAction: @selector(processCommandTest:) to: nil from: arg];
> See also fifth, sixth, and seventh.
>
> Fifth, note the use of the global constant NSApp instead of
> [NSApplication sharedApplication]. It's the same thing, only less
> effort to type.
>
> Sixth, a SEL is not an NSString. (Or if it is, it's only a coincidence
> of implementation.) Use the @selector() operator to generate SELs.
>
> Seventh, the name of a method that takes one argument ends with a
> colon. The colon is not merely syntactical; it is part of the name.
> processCommandTest
> and
> processCommandTest:
> identify two different methods.
>
> -- F
>
> On 23 Jul 2004, at 11:35 AM, Bruce Truax wrote:
>
>> I agree that the responder chain is the correct way to do this, but I
>> am
>> having trouble making it work. At the end of my windowDidLoad
>> function in
>> my NSWindowController I have the following command:
>>
>> [[self window] makeFirstResponder:self];
>>
>> And the window controller object contains the processCommandTest
>> function.
>> In my dialog handler I pass the message to the first responder as
>> follows:
>>
>> NSApplication *thisApp = [NSApplication sharedApplication];
>> if ([thisApp respondsToSelector:(SEL)@"processCommandTest"]){
>>
>> [thisApp tryToPerform:(SEL)@"processCommandTest"
>> with:command];
>> }
>>
>> But the respondsToSelector method always returns NO.
_______________________________________________
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: Windows and Default Notification Center (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Real simple newbie question(s)
  • Next by Date: inspector binding through mainWindow.document
  • Previous by thread: Re: Windows and Default Notification Center
  • Next by thread: Design Principles
  • Index(es):
    • Date
    • Thread