PopUpImage
PopUpImage
- Subject: PopUpImage
- From: Alan Smith <email@hidden>
- Date: Thu, 16 Feb 2006 15:35:31 -0500
Hi everyone,
I have a window with a box and a button in it. When the button is clicked
the window expands and another box is made and placed next to the first.
Each box has a PopUpImage in it, they're just really cool popupbuttons, with
the icon of the Finder. The problem is that the icon of the menus in the
boxes that are made by the button's action are offset. The top of them are
cut off by the edge of the box. The variables and stuff are declared in the
header. That bit works. Here's the code.
- (void)awakeFromNib
{
//Makes a workspace
worker = [NSWorkspace sharedWorkspace];
//Gets the icon for the app
icon = [worker iconForFile:[worker fullPathForApplication:@"Finder"]];
//Then resizes it
[icon setSize:NSMakeSize(128,128)];
//Makes a PopUpImage
thePopMenu = [[PopUpImage alloc]initWithIcon:icon popIcon:nil];
//Then puts it in the box
[[theBox contentView] addSubview:thePopMenu];
//Makes an array for the boxes
boxArray = [[NSMutableArray alloc] initWithCapacity:1];
//Then adds the already made box
[boxArray addObject:theBox];
}
- (IBAction)buttonIsClicked:(id)sender
{
//Makes theWindow a little bigger
[theWindow setContentSize: NSMakeSize(([theWindow frame].size.width +
[theBox frame].size.width), 202)];
//Gets the coordinates for the last box
NSRect position = [[boxArray lastObject] frame];
//Then adds on to move it over
position.origin.x += NSWidth(position);
//Makes a new box
newBox = [[NSBox alloc] initWithFrame:position];
//Then adds it to the window
[[theBox superview] addSubview:newBox];
//Adds the current box to the array
[boxArray addObject:newBox];
//Makes a new PopUpImage
thePopMenu = [[PopUpImage alloc]initWithIcon:icon popIcon:nil];
//Then adds it to the box
[[[boxArray lastObject] contentView] addSubview:thePopMenu];
}
If you understood all that, congratulations! I hope you found the problem.
The, awesome, thing called a PopUpImage was made by a guy who has some
awesome source code. It's definitely worth checking out, even if you didn't
figure out my problem. http://iratescotsman.com/products/source/ There is
some quite useful stuff there. Check it out!!
I'm not him, I just like his stuff, Alan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden