contextual menu and NSTextField
contextual menu and NSTextField
- Subject: contextual menu and NSTextField
- From: Arthur Clemens <email@hidden>
- Date: Fri, 13 Sep 2002 12:53:53 +0200
For some reason I cannot get a contextual menu to work for a
NSTextField.
In my AppController I have a text field IBOutlet
TextFieldWithContextualMenu *inputField;
In its init method I use this:
@implementation TextFieldWithContextualMenu
- (id)init {
printf("TextFieldWithContextualMenu init\n");
NSMenu *menu;
NSMenuItem *item;
int i;
NSString *path;
NSArray *charArray;
NSDictionary *defaultValues;
if (self = [super init]) {
path = [[NSBundle mainBundle]
pathForResource:@"Chars" ofType:@"plist"];
defaultValues = [NSDictionary dictionaryWithContentsOfFile:
path];
charArray = [defaultValues objectForKey:@"tags"];
menu = [[NSMenu alloc] initWithTitle:@"Menu"];
for (i=0; i<[charArray count]; i++) {
item = [[NSMenuItem alloc] init];
[item setTitle: [charArray objectAtIndex: i]];
[item setTarget: self];
[item setAction:@selector(insert:)];
[menu addItem: item];
[item release];
}
[self setMenu: menu];
NSLog(@"self menu = %@", [self menu]);
[menu release];
}
return self;
}
but the init method is never called.
In IB I have made the right connection and set the text field a custom
class: TextFieldWithContextualMenu.
Arthur Clemens
_______________________________________________
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.