views:

130

answers:

1

I have a text field with a background but to make it look right the text field needs to have some padding on the left side of it a bit like the NSSearchField does. How would I give the text field some padding on the left?

+3  A: 

Use a custom NSTextFieldCell that overrides drawingRectForBounds:. Have it inset the rectangle by however much you want, then pass than new rectangle to [super drawingRectForBounds:] to get the normal padding, and return the result of that call.

smorgan
I see, What would I put in the method to define how much I want it to be inset or is there some example code of this?
Joshua
Try http://www.cocoadev.com/index.pl?NSRect if you are unfamiliar with NSRect.
smorgan
Thanks for that link, Would I use this function "NSRect NSMakeRect(float x, float y, float w, float h)" inside the method and change the x,y,w and h to make it inset?
Joshua
Am I right about that?
Joshua
Am I correct to think that?
Joshua