Re: NSTextField, drawing the text offset to the right in the field
Re: NSTextField, drawing the text offset to the right in the field
- Subject: Re: NSTextField, drawing the text offset to the right in the field
- From: Matt Neuburg <email@hidden>
- Date: Wed, 30 Sep 2009 09:09:19 -0700
- Thread-topic: NSTextField, drawing the text offset to the right in the field
Although, to be clear, you *can* do this is in code, just not the way you
were doing it. You have to make sure you're talking to this instance at the
right moment, i.e. before the window appear but after the instance (the text
field) has been assembled by the nib. That moment, of course, is
awakeFromNib.
So, in awakeFromNib, instantiate the cell (you know, alloc-init etc.) and
set the textfield's cell - not its cell class, its *cell* - to that cell
instance:
[theTextField setCell: theCell];
If you do this in the text field's own awakeFromNib, then *all* text field's
of this class will adopt the custom cell.
[self setCell: theCell];
Or you can do it from elsewhere to specify that just *particular* text
fields should adopt the custom cell.
m.
On Tue, 29 Sep 2009 20:06:08 -0600, jon <email@hidden> said:
>ahh, that was it, thanks a lot, that made perfect sense once i
>looked inside IB....
>I was also surprised that IB knew about my custom cell class...
>
>I was thinking code code code... and i just needed that shove in the
>correct direction...
>you made my day, after a very long day...
>On Sep 29, 2009, at 7:58 PM, Kyle Sluder wrote:
>
>> +setCellClass: just tells the view "Hey next time you initialize
>> yourself, make a cell of this class." Since your ImageTextField
>> instance was created inside of IB, this is never going to happen.
>> Instead you need to change the class of the cell from within IB, under
>> the Identity inspector. It might be helpful to switch to the
>> hierarchical view so you can get easy access to the text field's cell.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden