Custom NSTextField Cell
Custom NSTextField Cell
- Subject: Custom NSTextField Cell
- From: Todd Yandell <email@hidden>
- Date: Tue, 2 Aug 2005 14:44:46 -0500
Hi,
This seems like it would be easy, but I can't find anything on it.
Here's what I want to do: I have a subclass of NSTextFieldCell that
draws itself a little differently that the standard one. I want to
embed it in an NSTextField, but Interface Builder doesn't have any
way to do this. I subclassed the NSTextField itself, too, but of
course it only gets an initWithCoder: message when it's pulled out of
the nib, and I have no way of specifying that it uses my cell instead
of the default NSTextFieldCell.
So, in short, how do I tell NSTextField to use my cell instead of the
default one?
Right now I'm using the code below. It seems like it's a pretty bad
hack, but it does seem to work. If there's no simple way to
substitute a control's cell for another, what do you think of this?
Is there anything wrong or dangerous with it?
(This code comes from my NSTextField subclass):
- (id)initWithCoder:(NSCoder *)coder
{
[(NSKeyedUnarchiver *)coder setClass:
[AOEditLabelCell class] forClassName:@"NSTextFieldCell"];
return [super initWithCoder:coder];
}
Thanks,
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