views:

93

answers:

1

I want to have a check box, like the standard one (first the check box and on the right its title) but I want it to be aligned from the right. If I change the alignment to the right then only the text will move to the right but the button itself will still be at the left.

How would I achieve this without knowing the bounds of the NSButton?

A: 

Read about Interface Layout in the Interface Builder user guide. As it turns out, just make your checkbox as big as you need to initially, and then set the struts and springs to make it resize correctly as it changes.

To do the same thing in code, read about the setAutoresizingMask: method in NSView.

Jim Puls
"without knowing the bounds of the NSButton", I only change the title but I don't know how long it'll be so it will be a problem determining the bounds.
Why wouldn't you know the bounds of the NSButton? Just call -bounds on it. Once you position it correctly for its current size and set the autoresizing mask, future size changes will be taken care of for you.
Jim Puls
I still think I'm missing something here; changing its title won't resize it automatically... Isn't the autoresizing mask only for when its super view changes its bounds?