Teo Choong Ping
Teo Choong Ping

Reputation: 12808

How to limit the length of text for labels?

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?

Upvotes: 0

Views: 253

Answers (2)

Richard Stahl
Richard Stahl

Reputation: 364

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

Upvotes: 0

Jorge Israel Peña
Jorge Israel Peña

Reputation: 38586

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

Upvotes: 1

Related Questions