Skip to content

Instantly share code, notes, and snippets.

Created November 3, 2008 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/21968 to your computer and use it in GitHub Desktop.
Save anonymous/21968 to your computer and use it in GitHub Desktop.
import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
var theWindow;
var toolbar;
//The variables in question
var pupupButton;
var menuItem;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
toolbar = [[CPToolbar alloc] initWithIdentifier:@"EditingToolbar"];
[toolbar setDelegate:self];
[theWindow setToolbar:toolbar];
[theWindow orderFront:self];
}
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)aToolbar
{
return ["FOO"];
}
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)aToolbar
{
return ["FOO"];
}
- (CPToolbarItem)toolbar:(CPToolbar)aToolbar itemForItemIdentifier:(CPString)anItemIdentifier willBeInsertedIntoToolbar:(BOOL)aFlag
{
var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:anItemIdentifier];
[toolbarItem setMinSize:CGSizeMake(240, 24)];
[toolbarItem setMaxSize:CGSizeMake(240, 24)];
var modeButton = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0, 0, 120, 24)];
[modeButton setTarget:self];
[modeButton setAction:@selector(test:)];
[modeButton setTitle:"Option 1"];
[modeButton setPullsDown:YES];
[modeButton addItemWithTitle:"Option 2"];
menuItem = [modeButton itemWithTitle:"Option 2"];
[menuItem setTag:5];
[toolbarItem setView:modeButton];
[toolbarItem setLabel:"Choose an Option"];
return toolbarItem;
}
- (void)test:(id)sender
{
console.log("This should be object "+menuItem+" and tag '"+[menuItem tag]+"'. Actual yield: "+[sender selectedItem]+" and tag "+[[sender selectedItem] tag]+". If there is some archiving/copying going on, it is not getting all attributes...");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment