• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Solved] Custom NSPopUpButton and Cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: [Solved] Custom NSPopUpButton and Cell
      • From: Philip Dow <email@hidden>
References: 
 >Custom NSPopUpButton and Cell (From: Philip Dow <email@hidden>)
 >[Solved] Custom NSPopUpButton and Cell (From: Philip Dow <email@hidden>)

  • Prev by Date: Re: Using Zip executable in Cocoa Application
  • Next by Date: Re: [Solved] Custom NSPopUpButton and Cell
  • Previous by thread: [Solved] Custom NSPopUpButton and Cell
  • Next by thread: Re: [Solved] Custom NSPopUpButton and Cell
  • Index(es):
    • Date
    • Thread