Re: cocoa-dev digest, Vol 1 #733 - 17 msgs
Re: cocoa-dev digest, Vol 1 #733 - 17 msgs
- Subject: Re: cocoa-dev digest, Vol 1 #733 - 17 msgs
- From: Rainer Brockerhoff <email@hidden>
- Date: Wed, 17 Oct 2001 16:32:38 -0200
>
Date: Wed, 17 Oct 2001 09:23:29 -0700
>
From: Jeff LaMarche <email@hidden>
>
>
I've hit two snags:
>
...
>
2. This is more of a question than a snag, but I have a singleton window
>
in my main NIB and two windows each with its own NIB and controller.
>
They work correctly with the exception of the File menu option "Close"
>
does not enable when either window becomes key. Now, I know how I can
>
enable the menu item, but it seems that this behavior happens
>
automagically if you're using the Multi-Document architecture, so I
>
didn't want to go implement functionality that's provided for me. Is
>
there some way to have this happen, or do I need to manually enable and
>
disable the File--> Close menu item?
Depends on what you would call "manually"...
I've just had to change my XRay utility from being NSDocument-based to rolling my own document model object. <aside> because of overly helpful symbolic-link following behavior by #$%^* Cocoa ;-) </aside>
Anyway, the solution I've found to this sort of thing is nearly automatic.
Just implement the following in the window's delegate:
- (BOOL)validateMenuItem:(NSMenuItem*)item {
BOOL result = YES;
SEL action = [item action];
if (action==@selector(performClose:) {
result = [self checkIfWindowIsCloseableOrSomethingLikeThat];
} else if ... // check for other menu items
}
return result;
}
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ (updated Oct. 2001)