Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created July 9, 2010 18:16
Show Gist options
  • Save jerodsanto/469817 to your computer and use it in GitHub Desktop.
Save jerodsanto/469817 to your computer and use it in GitHub Desktop.
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var button = [[TestButton alloc] initWithFrame:CGRectMake(0,0,100,24)];
[button addItemWithTitle:@"one"];
[button addItemWithTitle:@"two"];
[button addItemWithTitle:@"three"];
[button setCenter:[contentView center]];
[contentView addSubview:button];
[theWindow orderFront:self];
}
@end
@implementation TestButton : CPPopUpButton
{
}
- (void)menuDidChangeItem:(CPNotification)aNotification
{
var index = [[aNotification userInfo] objectForKey:@"CPMenuItemIndex"];
console.log('menu did change, index = ', index);
if ([self pullsDown] && index != 0)
return;
if (![self pullsDown] && index != _selectedIndex)
return;
[self synchronizeTitleAndSelectedItem];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment