Re: Custom NSTextField Cell
Re: Custom NSTextField Cell
- Subject: Re: Custom NSTextField Cell
- From: Todd Yandell <email@hidden>
- Date: Tue, 2 Aug 2005 16:23:53 -0500
Can't you just drop a standard cell and set it up in
interfacebuilder, but then set it's Custom Class (one of the panels
in the inspector) to your class? (make sure you drag your class
header into your nib window)
...
Then you will need to also subclass NSTextField and have it specify
your custom cell, rather than its default. Drag the header for your
custom text field to IB, then use the Custom Class palette to tell
your pre-configured text field to use your custom class instead of
NSTextField.
I don't have any problems setting the actual control to use my
subclassed NSTextField control in IB. The problem lies in the fact
that Interface Builder, as far as I can tell, will only use
NSTextFieldCell on the text field, regardless of what class you use
for the control. So I can have the text field use my subclassed
NSTextField, but IB still archives it with an NSTextFieldCell as it's
cell.
Really, the entire problem is that IB has archived the text field
using the NSTextFieldCell. When I load the nib my control subclass
correctly gets the "initWithCoder:" message, just as it should, but
that coder has NSTextFieldCell archived as it's cell class, *not* my
cell class. So, I believe that leaves me with two options:
1. Drop the cell that comes from the archived nib and replace it with
my own. This is easy enough, but it means that all of the settings I
set in IB have to be redone in code, so I may as well have created
the entire control itself in code. This is fine, but I'd rather…
2. Create the control in IB, set it to use my NSTextField subclass
*and* my NSTextFieldCell subclass, and not have to worry about
writing any code to swap out the cell.
If the second option is simply not possible, that's OK, it's not a
big deal to write a little code. I just want to make sure I'm not
missing some setting or panel in IB that let's me use a custom cell
subclass without having to swap them out in code. Or, am I missing
something else altogether? What, exactly, did you mean by, "have it
specify your custom cell"? I tried overriding "+cellClass" in my
NSTextField subclass, but that had no effect.
Thanks, I really do appreciate all of your help!
Todd _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden