Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make NSTextField use custom subclass of NSTextFieldCell?

I've been looking for a solution to make my NSTextField bottom-aligned and I've found this and adjusted it for my needs. So now I have this custom NSTextFieldCell but how do I tell my NSTextFields to use this class (programmatically)?

like image 453
iMaddin Avatar asked Jul 02 '12 11:07

iMaddin


2 Answers

Since you ask how to do it programmatically, you can also use the setCellClass: method on your NSTextField subclass. Call it in the load or initialize class methods:

+(void)load
{
    [self setCellClass:[MyTextFieldCell class]];
}

It will not have any bearing on your text fields defined in Interface Builder, as the text field cell set there takes precedence.

like image 149
Monolo Avatar answered Nov 15 '22 15:11

Monolo


Have you tried setCell: method of the NSControl class?

- (void)setCell:(NSCell *)aCell
like image 4
Bruno Ferreira Avatar answered Nov 15 '22 14:11

Bruno Ferreira