Yes, I had done that before also to no avail. But thinking I might have been tired and erred I have done it again. Still does not work. I am including the code and a link to a debug picture that shows all is set correctly (as far as I can tell).
Would someone be willing to run this code and post results?
Might Apple comment or weigh in on this?

- db

The code: (in this example I moved cp to be an ivar thinking there was some scope issue)


NSColorPanel* cp;


- (IBAction)color:(id)sender {

        
        cp = [NSColorPanel sharedColorPanel];
        [cp setDelegate:self];
        [cp setTarget:self];
        [cp setAction:@selector(changeColor:)];
        [cp setContinuous:YES];
        [NSApp runModalForWindow:cp];
        [cp orderOut:cp];
}

- (void)changeColor:(id)sender {

        NSLog(@"changeColor");
}

- (void)windowWillClose:(NSNotification *)notification {

        [NSApp stopModalWithCode:0];
}


A link to an annotated picture of the variables

http://crusaderrabbit.net/NSColorPanel.jpg






On Feb 25, 2010, at 12:30 AM, Graham Cox wrote:

Ah, your reply prompted me to review the documentation, which I believe is in error.

It's not the delegate that gets sent this message, it's the panel's target. use -setTarget: instead. -changeColor: is also sent to the responder chain regardless.

The documentation lists -changeColor: under "delegate methods" but the panel only inherits the delegate methods of NSWindow, etc.

--Graham





On 25/02/2010, at 6:21 PM, David Blanton wrote:

Well, no.

I have run it

        modal from a modal panel
        non-modal from a modal panel
        non-modal from a non-modal panel

changeColor is never called.

I am stumped and going to pour a glass of wine and play a game of chess !

- db

On Feb 24, 2010, at 11:53 PM, Graham Cox wrote:


On 25/02/2010, at 5:44 PM, David Blanton wrote:

Am I missing something obvious?


Generally apps don't run the color panel modally. I believe there is a way to do it, I've seen it in some apps with an added OK/ Cancel button, though it seems rare and weird. It may be that running it this way works differently, or maybe what you're doing is just unsupported.





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to