• 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
[Solved] Custom NSPopUpButton and Cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Solved] Custom NSPopUpButton and Cell


  • Subject: [Solved] Custom NSPopUpButton and Cell
  • From: Philip Dow <email@hidden>
  • Date: Sat, 17 Dec 2005 12:27:05 +0100

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;
}


On Dec 10, 2005, at 8:28 PM, Philip Dow wrote:

Hiya,

I've managed to subclass a popup button and cell to display a custom look, similar to the "More Info..." button in the finder but for a popup button. I am overriding drawInteriorWithFrame:inView: to do my drawing, which handles the work just fine. However, I am unable to get a menu when I click on the button.

When I click, instead of the full menu set in IB, I end up with a single item menu which contains the item currently selected by the popup button. Am I missing a method somewhere that I need to override or call from my drawing code? The button is already set to flip, and I have tried [[self cell] setMenu:[self menu]]; in the button's awakeFromNib method, as recommended on cocoadev, but to no avail.
_______________________________________________
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


_______________________________________________
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: Uli Kusterer <email@hidden>
References: 
 >Custom NSPopUpButton and Cell (From: Philip Dow <email@hidden>)

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