FROM : John Spicer
DATE : Fri Nov 19 19:52:12 2004
Yes, setting the target fixes this problem. Thanks to all who answered.
What really gets me is that I use this code in another place to build a
different menu, and THOSE items are enabled.
I'm doing something wrong, I just know it.
On Nov 19, 2004, at 12:57 PM, <email_removed> wrote:
>> I'm building a menu at run-time. I add items to the menu, and each one
>> is given a selector as shown.
>>
>> The menu items won't enable. I'm not setting a target for the menu
>> item, only a selector. Is this possibly the problem?
>
> Yup thats the problem. Seems silly, but you do have to set the target.
>
>>
>> The code I'm using is shown below:
>>
>> NSMenu *theMenuBar = [NSApp mainMenu];
>> NSMenuItem *theView = [theMenuBar itemWithTitle:@"MyMenu"];
>> NSMenu *myMenu = [theView submenu];
>>
>> for (int i = 0; i< [inData count]; i++)
>> {
>> NSDictionary *d = [inData objectAtIndex:i];
>> NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[d
>> objectForKey:@"Name"] action:@selector(somethingWasChoosen:)
>> keyEquivalent:@""];
>> [item setTag:[[d objectForKey:@"Code"] intValue]];
>> [myMenu addItem:item];
>> }
>>
>>
>> and later somethingWasChoosen is defined as:
>>
>> - (IBAction) somethingWasChoosen:(id)sender
>> {
>> }
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/
>> <email_removed>
>>
>> This email sent to <email_removed>
>
>
DATE : Fri Nov 19 19:52:12 2004
Yes, setting the target fixes this problem. Thanks to all who answered.
What really gets me is that I use this code in another place to build a
different menu, and THOSE items are enabled.
I'm doing something wrong, I just know it.
On Nov 19, 2004, at 12:57 PM, <email_removed> wrote:
>> I'm building a menu at run-time. I add items to the menu, and each one
>> is given a selector as shown.
>>
>> The menu items won't enable. I'm not setting a target for the menu
>> item, only a selector. Is this possibly the problem?
>
> Yup thats the problem. Seems silly, but you do have to set the target.
>
>>
>> The code I'm using is shown below:
>>
>> NSMenu *theMenuBar = [NSApp mainMenu];
>> NSMenuItem *theView = [theMenuBar itemWithTitle:@"MyMenu"];
>> NSMenu *myMenu = [theView submenu];
>>
>> for (int i = 0; i< [inData count]; i++)
>> {
>> NSDictionary *d = [inData objectAtIndex:i];
>> NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[d
>> objectForKey:@"Name"] action:@selector(somethingWasChoosen:)
>> keyEquivalent:@""];
>> [item setTag:[[d objectForKey:@"Code"] intValue]];
>> [myMenu addItem:item];
>> }
>>
>>
>> and later somethingWasChoosen is defined as:
>>
>> - (IBAction) somethingWasChoosen:(id)sender
>> {
>> }
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/
>> <email_removed>
>>
>> This email sent to <email_removed>
>
>
| Related mails | Author | Date |
|---|---|---|
| John Spicer | Nov 19, 19:02 | |
| Jesus De Meyer | Nov 19, 19:06 | |
| John Spicer | Nov 19, 19:52 | |
| Glenn Andreas | Nov 19, 20:07 |






Cocoa mail archive

