Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)resizeAccountChooser
- {
- // accountChooser = the NSPopUpButton
- // mainWindow = the window it's attached to
- // userSelectionAccessoryView = the NSView that contains the popup button
- NSDictionary *displayAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[accountChooser font], NSFontAttributeName, nil];
- NSSize titleSize = [[[accountChooser selectedItem] title] sizeWithAttributes:displayAttributes];
- NSView *themeFrame = [[mainWindow contentView] superview];
- NSRect c = [themeFrame frame]; // c for "container"
- NSRect aV = [userSelectionAccessoryView frame]; // aV for "accessory view"
- NSRect aC = [accountChooser frame];
- CGFloat rightDistance = aV.size.width - (aC.origin.x + aC.size.width);
- aC.size.width = titleSize.width + 31;
- aC.origin.x = aV.size.width - (rightDistance + aC.size.width);
- [accountChooser setFrame:aC];
- NSRect newFrame = NSMakeRect(c.size.width - aV.size.width, // x position
- c.size.height - aV.size.height, // y position
- aV.size.width, // width
- aV.size.height); // height
- [userSelectionAccessoryView setFrame:newFrame];
- }
Add Comment
Please, Sign In to add comment