Guest User

Untitled

a guest
Jun 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. - (void)resizeAccountChooser
  2. {
  3. // accountChooser = the NSPopUpButton
  4. // mainWindow = the window it's attached to
  5. // userSelectionAccessoryView = the NSView that contains the popup button
  6. NSDictionary *displayAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[accountChooser font], NSFontAttributeName, nil];
  7. NSSize titleSize = [[[accountChooser selectedItem] title] sizeWithAttributes:displayAttributes];
  8. NSView *themeFrame = [[mainWindow contentView] superview];
  9.  
  10. NSRect c = [themeFrame frame]; // c for "container"
  11. NSRect aV = [userSelectionAccessoryView frame]; // aV for "accessory view"
  12.  
  13. NSRect aC = [accountChooser frame];
  14. CGFloat rightDistance = aV.size.width - (aC.origin.x + aC.size.width);
  15. aC.size.width = titleSize.width + 31;
  16. aC.origin.x = aV.size.width - (rightDistance + aC.size.width);
  17. [accountChooser setFrame:aC];
  18.  
  19. NSRect newFrame = NSMakeRect(c.size.width - aV.size.width, // x position
  20. c.size.height - aV.size.height, // y position
  21. aV.size.width, // width
  22. aV.size.height); // height
  23. [userSelectionAccessoryView setFrame:newFrame];
  24. }
Add Comment
Please, Sign In to add comment