FW: Enabling and Disabling menus
FW: Enabling and Disabling menus
- Subject: FW: Enabling and Disabling menus
- From: "Stuppel, Searle @ San Diego Central" <email@hidden>
- Date: Wed, 22 Aug 2001 12:07:15 -0700
this is not the way to do it... let me share with you the code that actually
WORKS
//// the .h:
#import <Cocoa/Cocoa.h>
@interface MyMenu : NSMenu
{
IBOutlet id menuClear;
IBOutlet id menuGenerate;
IBOutlet id menuSaveHTML;
IBOutlet id menuSaveText;
SEL actClear, actGenerate, actSaveHTML, actSaveText;
}
- (void)setMenu:(id)sender mG:(BOOL)gen mC:(BOOL)cle mST:(BOOL)mst
mSH:(BOOL)msh;
@end
//// the .m
#import "MyMenu.h"
#import "Controller.h"
@implementation MyMenu
-(void)awakeFromNib
{
actGenerate = [menuGenerate action];
actClear = [menuClear action];
actSaveText = [menuSaveText action];
actSaveHTML = [menuSaveHTML action];
}
- (void)setMenu:(id)sender mG:(BOOL)gen mC:(BOOL)cle mST:(BOOL)mst
mSH:(BOOL)msh
{
if (gen) {
[menuGenerate setAction:actGenerate];
}
else {
[menuGenerate setAction:0];
}
if (cle) {
[menuClear setAction:actClear];
}
else {
[menuClear setAction:0];
}
if (mst) {
[menuSaveText setAction:actSaveText];
}
else {
[menuSaveText setAction:0];
}
if (msh) {
[menuSaveHTML setAction:actSaveHTML];
}
else {
[menuSaveHTML setAction:0];
}
}
@end
/// the actual call from another file:
[menuLink setMenu:self mG:YES mC:NO mST:NO mSH:NO];
--- where menuLink is an outlet link from the calling file to the menu file.
--- also you need to import the menu files .h file if you land up doing this
in separate files
let me know if this helps
searle
Searle Stuppel
CB Richard Ellis, Inc.
Direct: 858-546-4600
Fax: 858-546-4616
Toll Free: 800-334-9347
email@hidden
-----Original Message-----