• 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: PopUpButton with a custom apparence using an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PopUpButton with a custom apparence using an image


  • Subject: Re: PopUpButton with a custom apparence using an image
  • From: Alessandro de Peppo <email@hidden>
  • Date: Wed, 3 Sep 2003 18:51:12 +0200

At 16:28 +0200 3-09-2003, j o a r wrote:
>Have you looked at "/Developer/Examples/AppKit/MenuMadness"?
>
>j o a r

Thanks joar! :-)
I was able to realize my custom PopUpButton very quickly, without any subclass.
But there is one little problem: I can't set an alternate image (or just an
highlight) on my button to have some feedback when button is pressed and
menu is displayed.
here's my code snippet:

- (void)createPullDownMenu
{
NSMenuItem *item;

pullDown = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(124.0,
([[window contentView] frame].size.height - 44.0), 78.0, 34.0)
pullsDown:YES];

[[pullDown cell] setBordered:NO];
[[pullDown cell] setImagePosition:NSImageOnly];
[[pullDown cell] setArrowPosition:NSPopUpNoArrow];


[pullDown addItemsWithTitles:[NSArray arrayWithObjects:@"title",
@"One", @"Two", @"Three", @"Four", @"Five", @"Six", @"Seven", @"Eight",
@"Nine", @"Ten", @"Eleven", @"Twelve", @"Thirteen", @"Fourteen",
@"Fifteen", nil]];
[[pullDown cell] setUsesItemFromMenu:NO];
item = [[NSMenuItem allocWithZone:[self zone]] initWithTitle:@""
action:NULL keyEquivalent:@""];
[item setImage:[NSImage imageNamed:@"Pop"]];
[item setOnStateImage:nil];
[item setMixedStateImage:nil];
[[pullDown cell] setMenuItem:item];
[item release];
[pullDown setPreferredEdge:NSMinXEdge];
[[[pullDown menu] menuRepresentation] setHorizontalEdgePadding:0.0];
[[window contentView] addSubview:pullDown];
}

Any ideas?

TIA,

Alessandro
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: PopUpButton with a custom apparence using an image (From: j o a r <email@hidden>)

  • Prev by Date: Re: Newbie question: forcing data format during saveDocumentTo:
  • Next by Date: Scroll position of a NSTextView
  • Previous by thread: Re: PopUpButton with a custom apparence using an image
  • Next by thread: How to hide Dock like iMovie does?
  • Index(es):
    • Date
    • Thread