• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Custom NSTextField Cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Custom NSTextField Cell
      • From: SA Dev <email@hidden>
  • Prev by Date: When is an Entity based (CoreData) NSArrayController ready with data?
  • Next by Date: Piano keyboard control?
  • Previous by thread: When is an Entity based (CoreData) NSArrayController ready with data?
  • Next by thread: Re: Custom NSTextField Cell
  • Index(es):
    • Date
    • Thread