• 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: Custom NSMenuItem/NSPopupButtonCell Drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSMenuItem/NSPopupButtonCell Drawing


  • Subject: Re: Custom NSMenuItem/NSPopupButtonCell Drawing
  • From: PGM <email@hidden>
  • Date: Mon, 16 Jul 2007 21:53:11 -0400

You can use the attributed string if you place a right text tab in the attributed string. You then only have to tweak your code for its position in order to get the tagword at the position you want:

NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
[paraStyle setTabStops:[NSArray array]];
[paraStyle addTabStop:[[[NSTextTab alloc] initWithType:NSRightTabStopType location:190.0] autorelease]];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:paraStyle forKey:NSParagraphStyleAttributeName];
NSAttributedString *titleString = [[[NSAttributedString alloc] initWithString:@"Hello\tworld" attributes:attributes] autorelease];
[[popUpButton itemAtIndex:0] setAttributedTitle:titleString];


Good luck, Patrick


On 16-Jul-07, at 18:13 PM, Mike Rossetti wrote:

Yes, and that's actually what I use right now. But it doesn't give me the ability to right-justify the 'LATE' tag within the drawing area.

On Jul 16, 2007, at 3:57 PM, Murat Konar wrote:
-[NSMenuItem setAttributedTitle:]

On Jul 16, 2007, at 2:51 PM, Mike Rossetti wrote:

Hello All,

I have a need to do some custom drawing within a menu item of a NSPopUpButtonCell. Essentially, within the menu item I need to draw the title to the left (like normal) and then a tagword to the right in red and in a bit smaller font. For example:

	My Item Title         LATE

where 'LATE' is drawn in red and right justified in the cell.

This is fairly straightforward to do for the quiescent state of the popup: just override drawWithFrame and render a couple of attributed strings.

But I'm having a dickens's of a time figuring out how to get what I want when the popup is popped up! There doesn't appear to be a convenient rendering function that I can override that renders the menu item while being popped up.

Surely I am missing something obvious here.  Any suggestions?

Thanks,
Mike

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Custom NSMenuItem/NSPopupButtonCell Drawing (From: Mike Rossetti <email@hidden>)
 >Re: Custom NSMenuItem/NSPopupButtonCell Drawing (From: Murat Konar <email@hidden>)
 >Re: Custom NSMenuItem/NSPopupButtonCell Drawing (From: Mike Rossetti <email@hidden>)

  • Prev by Date: Getting an NSAttributedString from NSData/NSTextView using Core Data
  • Next by Date: How to loop until kill command sent?
  • Previous by thread: Re: Custom NSMenuItem/NSPopupButtonCell Drawing
  • Next by thread: NSTokenField with NSSmallControlSize in a Table View
  • Index(es):
    • Date
    • Thread