Re: [Solved] Custom NSPopUpButton and Cell
Re: [Solved] Custom NSPopUpButton and Cell
- Subject: Re: [Solved] Custom NSPopUpButton and Cell
- From: Uli Kusterer <email@hidden>
- Date: Sat, 17 Dec 2005 20:21:47 +0100
Am 17.12.2005 um 12:27 schrieb Philip Dow:
Posted this guy about a week ago but didn't get a reply. Sat down
to it this morning and figured something out. I lose the IB menu
when I call
[self setCell:[[[PDPopUpButtonCell alloc] initTextCell:[self
title] pullsDown:[self pullsDown]] autorelease]];
in the initWithCoder method. I don't know why that's the case.
Turns out the solution is to save the menu, set my custom cell, and
reset the menu afterwards. I have no idea why this is necessary. If
anyone can shed some light on this...
- (id)initWithCoder:(NSCoder *)decoder {
if ( self = [super initWithCoder:decoder] ) {
NSMenu *tempMenu = [[self menu] copyWithZone:[self zone]];
[self setCell:[[[PDPopUpButtonCell alloc] initTextCell:[self
title] pullsDown:[self pullsDown]] autorelease]];
[self setMenu:tempMenu];
[tempMenu release];
}
return self;
}
My guess would be that the popup button cell owns the menu. When you
replace it with your cell subclass, the old cell is released,
releasing the menu as well. If you don't retain the menu yourself,
that would also cause the menu to go away.
Could that be the case?
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden