Subject: Re: NSPopUpButton not accepting setMenu: from WindowController code
Michael gave me the clue. I still had the window's owner as AppDelegate. When I
corrected that to the WindowController all is well. Details details.

~ Erik

On 2012-02-18, at 9:55 AM, Keary Suska wrote:

> On Feb 18, 2012, at 8:37 AM, Erik Stainsby wrote:
>
>>
>> [myPUBtn setMenu:menu] accepted in MyAppDelegate but does not accept
>> setMenu:menu when relocated to an NSWindowController. I'm thinking there is
>> something I have missed about the loading sequence.
>
> When you call this method, what object do you pass as "owner"? Is the outlet
> connected from the File's Owner, or an object in the same xib?
>
>> - (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner {
>> self = [super initWithWindowNibName:windowNibName owner:owner];
>> if (self) {
>> [self setActionPlugins:[self loadPluginsWithPrefix:@"Action"]];
>> }
>> return self;
>> }
>>
>>
>> - (void)windowDidLoad
>> {
>> [super windowDidLoad];
>> NSMenu * menu = [[NSMenu alloc] init];
>>
>> for(RSTrixiePlugin * p in actionPlugins)
>> {
>> NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle:[p
>> name] action:@selector(showActionPlugin:) keyEquivalent:@""];
>> [menuItem setRepresentedObject:p];
>> [menu addItem:menuItem];
>> NSLog(@"%s- [%04d] added action menu item for plugin: %@",
>> __PRETTY_FUNCTION__, __LINE__, [p name]);
>> }
>> [actionMenu setMenu:menu];
>> NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, menu);
>> // shows description of populated menu
>> NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[menu
>> itemArray] count]); // returns 2
>> NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[[actionMenu
>> menu] itemArray] count]); // returns 2
>> NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, [actionMenu
>> menu]); // (null)
>> [actionMenu setNeedsDisplay:YES]; // on a whim
>> }
>>
>>
>> [â]
>>
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com
>>
>> This email sent to cocoa-dev@xxxxxxxxxxxxxxx
>
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/maillists%40codeha.us

This email sent to maillists@xxxxxxxxx
(C)2011 mailinglist-archive.com