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
2009-07-27 14:10:31
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
2009-07-27 16:47:30
Try http://www.cocoadev.com/index.pl?NSRect if you are unfamiliar with NSRect.
smorgan
2009-07-27 18:02:16
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
2009-07-28 05:47:56
Am I right about that?
Joshua
2009-07-29 05:31:37
Am I correct to think that?
Joshua
2009-07-31 13:28:06