mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
18 lines
573 B
Plaintext
18 lines
573 B
Plaintext
#import "NSView Additions.h"
|
|
|
|
@implementation NSView (PopupAddition)
|
|
- (void)showMenu:(NSMenu*)menu inRect:(NSRect)rect withSelectedIndex:(NSInteger)index font:(NSFont*)font popup:(BOOL)isPopup
|
|
{
|
|
NSPopUpButtonCell* cell = [NSPopUpButtonCell new];
|
|
[cell setPullsDown:!isPopup];
|
|
if(!isPopup)
|
|
[menu insertItemWithTitle:@"dummy title item" action:NULL keyEquivalent:@"" atIndex:0];
|
|
[cell setFont:font];
|
|
[cell setAltersStateOfSelectedItem:NO];
|
|
[cell setMenu:menu];
|
|
if(index >= 0)
|
|
[cell selectItemAtIndex:index];
|
|
[cell performClickWithFrame:rect inView:self];
|
|
}
|
|
@end
|