How to make NSTextField use custom subclass of NSTextFieldCell?
Asked Answered
T

2

7

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)?

Talus answered 2/7, 2012 at 11:49 Comment(0)
M
4

Have you tried setCell: method of the NSControl class?

- (void)setCell:(NSCell *)aCell
Materials answered 2/7, 2012 at 12:8 Comment(0)
V
7

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.

Viscus answered 2/7, 2012 at 16:30 Comment(1)
looks like it's removed now :(Gerfalcon
M
4

Have you tried setCell: method of the NSControl class?

- (void)setCell:(NSCell *)aCell
Materials answered 2/7, 2012 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.