• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How can I right-justify items in an NSPopUpButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I right-justify items in an NSPopUpButton?


  • Subject: Re: How can I right-justify items in an NSPopUpButton?
  • From: Richard Jackson <email@hidden>
  • Date: Fri, 7 Jan 2005 13:56:24 -0800

Nope - but thanks for the suggestion!

With the attributed text titles I'm closer to what I want: when the NSPopUpButton is NOT clicked on I get my selected item with the title right-justified (yay!). But when I click on the NSPopUpButton, all of the item titles disappear: I just get a blank popup. It has the proper size and shape, and the checkmark appears next to the place where the currently-selected item would be, but no titles appear. I can make a selection, and when I let go of the button the correct title appears in the (closed) popup.

Here's my code: any ideas? (or is there a simpler way??)

Thanks!

   - Richard


- (void) buildPopup:(NSPopUpButton *)popup withTitles:(NSArray *)titles { [popup removeAllItems];

// make an NSParagraphStyle specifying right-alignment
NSMutableParagraphStyle *pgStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
[pgStyle setParagraphStyle:[NSParagraphStyle defaultParagraphStyle]];
[pgStyle setAlignment:NSRightTextAlignment];

// make an attributes dictionary with the Paragraph Style
NSDictionary *attr = [NSDictionary dictionaryWithObject:pgStyle forKey:NSParagraphStyleAttributeName];

int count = [titles count];
int i;
for (i = 0; i < count; i++)
{
NSString *titleString = (NSString *)[titles objectAtIndex:i];
NSAttributedString *attrTitle = [[[NSAttributedString alloc] initWithString:titleString attributes:attr] autorelease];
[popup addItemWithTitle:titleString];
[[popup lastItem] setAttributedTitle:attrTitle];
}
}




On Jan 7, 2005, at 12:46 PM, M. Uli Kusterer wrote:

At 12:36 Uhr -0800 07.01.2005, Richard Jackson wrote:
   I'm sure there's a way - I just can't seem to find it...

I have an NSPopUpButton with multiple items, and I'd like the items to be RIGHT-justified in the popup when it comes up (sounds silly, but it's a numerical application and the items are decimal digits which would look better right-justified).

Have you tried using setAttributedTitle: on the popup button items to pass in a right-aligned string?
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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


_______________________________________________ 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
References: 
 >Re: Drawing scaled lines (From: Robert Clair <email@hidden>)
 >Re: Drawing scaled lines (whoops) (From: Robert Clair <email@hidden>)
 >How can I right-justify items in an NSPopUpButton? (From: Richard Jackson <email@hidden>)
 >Re: How can I right-justify items in an NSPopUpButton? (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: WYSIWIG drawing vs printing (was drawing scaled lines)
  • Next by Date: Properly loading cocoa applications as modules
  • Previous by thread: Re: How can I right-justify items in an NSPopUpButton?
  • Next by thread: Re: Drawing scaled lines
  • Index(es):
    • Date
    • Thread