views:

452

answers:

3

Any way to have a NSButton title to wrap when it's width is longer than the button width, instead of getting clipped?

I'm trying to have a radio button with a text that can be long and have multiple lines. One way I thought about having it work is to have an NSButton of type NSRadioButton but can't get multiple lines of text to work.

Maybe my best alternative is to have an NSButton followed by an NSTextView with the mouseDown delegate function on it triggering the NSButton state?

+5  A: 

I don't believe you can. You'd have to subclass NSButtonCell to add support for this.

That said, it's typically a bad idea to have multiple lines of text on a button. A button label should concisely represent the action performed:

The label on a push button should be a verb or verb phrase that describes the action it performs—Save, Close, Print, Delete, Change Password, and so on. If a push button acts on a single setting, label the button as specifically as possible; “Choose Picture…,” for example, is more helpful than “Choose…” Because buttons initiate an immediate action, it shouldn’t be necessary to use “now” (Scan Now, for example) in the label.

What are you trying to do?

Sören Kuklau
+1  A: 

I'm with Sören; If you need a longer description, think about using a tool tip or placing descriptive text in a wrapped text field using the small system font below the radio choices if the descriptive text is only a few lines. Otherwise, you could provide more information in a help document.

Figuring out a way to say what you need to say in a concise way is your best bet, though.

Wevah
I absolutely need to show the associated text with each radio button option "as is", each is a possible answer to a question shown on top, all coming from db and resuming is not an option. I ended up adding a wrapped text view on the right of each radio button and controlling the height dynamically.
carlosb
Ah, context. That makes a lot more sense!
Wevah
A: 

Carlosb,

I am having the same issue as you with my check boxes in a NSMatrix. The cells need wo word wrap becuase iy is an exam. How did you implement yours, are you using the matrix becuase I don't see a way to add a text view and the attributedTitle propery refuses to wrap.

Thanks

FdB

Fluffy D. Bunny
I've used a separate NSTextView control, but not inside an NSMatrix. In your case you may have to have a NSView that combines both and add that to the NSMatrix.
carlosb
the way that it is currently implemented is an NSMatrix with NSButtonCells using AttributedTitle. But AttributedTitle seems to ignore wordwrap. Is there a better way to get checkboxes with rtf text that is word wrappable? Thanks for helping btw.
Fluffy D. Bunny