Re: Creating Menu Items Programmatically.
Re: Creating Menu Items Programmatically.
- Subject: Re: Creating Menu Items Programmatically.
- From: Stéphane Sudre <email@hidden>
- Date: Thu, 13 Feb 2003 12:36:01 +0100
On Thursday, February 13, 2003, at 12:23 PM, Steve wrote:
Hi,
I'm trying to populate a valid NSMenu (called menuInPort) with menu
items created in a loop.
If I use an empty string, I have established that the menu items are
being created Ok.
1) What's the most convenient way to just turn the (long)portNum in to
a string that initWithTitle will accept?
(I don't really have to write NSNumber and formatting code do
I??)
2) The selector (which is part of the same controller class) is not
being called. I have an idea that the newly created items might
mistakenly think the First Responder is the target.
long portNum;
NSMenuItem *menItem;
for( portNum=1; portNum <=numInputs; portNum ++)
{
menItem = [NSMenuItem alloc];
[menItem initWithTitle :portNum:@selector(setInputPort)
keyEquivalent:@""];
[menuInPort addItem:menItem];
}
//--------------------------------
- (IBAction) setInputPort:(id)sender
{
// Do stuff.
}
long portNum;
NSMenuItem *menItem;
for( portNum=1; portNum <=numInputs; portNum ++)
{
menItem = [[NSMenuItem alloc] initWithTitle:[NSString
stringWithFormat:@"%ld",portNum] action:@selector(setInputPort:)
keyEquivalent:@""];
[menItem setTarget:myTarget];
[menuInPort addItem:menItem];
}
_______________________________________________
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.