tags:

views:

50

answers:

2

This could be really easy but I it's not obvious when I google it.

I have few NSMenuItem items that get populated at runtime and the label can be very long.How do set a limit for the title with the "..." in the middle of the text?

+1  A: 

You could write your own method to preprocess the text before it is set to the label, and adds in ... on your own terms.

Jorge Israel Peña
Better yet, use the … character, not the ... string.
Peter Hosey
that's exactly what I did. I created a NSString category and have a function that takes in a int param that will limit the text length and add in the "..." char at the end of the string. This sure beats having to use NSTextView.
Seymour Cakes
+1  A: 

Another possibility: grab the NSMenuItemCell from the menu item and set its line break mode to NSLineBreakByTruncatingMiddle

Richard Stahl