Re: How can I right-justify items in an NSPopUpButton?
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