Re: PopUpButton with a custom apparence using an image
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.