Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/helpers-mac/NSMenu+ppaddons.m @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #import "NSMenu+ppaddons.h" | |
| 2 | |
| 3 @implementation NSMenu (ppaddons) | |
| 4 | |
| 5 - (NSMenuItem*) pp_addItemWithTitle: (NSString*) title action: (SEL) action target: (id) target { | |
| 6 NSMenuItem * item = [[NSMenuItem alloc] initWithTitle: title action: action keyEquivalent: @""]; | |
| 7 item.target = target; | |
| 8 [self addItem: item]; | |
| 9 return item; | |
| 10 } | |
| 11 | |
| 12 - (void) pp_addSeparator { | |
| 13 [self addItem: [NSMenuItem separatorItem]]; | |
| 14 } | |
| 15 | |
| 16 - (NSMenuItem*) pp_addSubMenu: (NSMenu*) menu withTitle: (NSString*) title { | |
| 17 NSMenuItem * item = [[NSMenuItem alloc] init]; | |
| 18 item.title = title; | |
| 19 item.submenu = menu; | |
| 20 [self addItem: item]; | |
| 21 return item; | |
| 22 } | |
| 23 | |
| 24 - (void)pp_popUpForView:(NSView *)view { | |
| 25 BOOL pullsDown = YES; | |
| 26 NSMenu *popMenu = [self copy]; | |
| 27 NSRect frame = [view frame]; | |
| 28 frame.origin.x = 0.0; | |
| 29 frame.origin.y = 0.0; | |
| 30 | |
| 31 if (pullsDown) [popMenu insertItemWithTitle:@"" action:NULL keyEquivalent:@"" atIndex:0]; | |
| 32 | |
| 33 NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:pullsDown]; | |
| 34 [popUpButtonCell setMenu:popMenu]; | |
| 35 if (!pullsDown) [popUpButtonCell selectItem:nil]; | |
| 36 [popUpButtonCell performClickWithFrame:frame inView:view]; | |
| 37 } | |
| 38 | |
| 39 @end |
