NSTextField with custom cell - is it even possible?
NSTextField with custom cell - is it even possible?
- Subject: NSTextField with custom cell - is it even possible?
- From: Andy <email@hidden>
- Date: Sun, 21 Jul 2002 02:37:25 -0400
So as I said earlier today, I want to make a custom NSTextFieldCell subclass.
Using the list archives, and a little intuition, this should work:
#import "LineBoxField.h"
@implementation LineBoxField
+ (Class) cellClass {
return [LineBoxFieldCell class];
}
+ (void) setCellClass: (Class) classId {
//you cannot change the class once setup
[NSException raise: NSInvalidArgumentException format: @"You cannot
change the class used for the cell"];
}
- (id) initWithFrame: (NSRect) frameRect {
[super initWithFrame: frameRect];
return self;
}
- (id) initWithCoder: (NSCoder *) decoder {
[super initWithCoder: decoder];
return self;
}
@end
But, if one drags an NSTextField into a window in Interface Builder,
then sets its Custom Class to LineBoxField,
and execute this code in a handy spot:
NSLog(@"cell class: %@", [LineBoxField cellClass]);
NSLog(@"cell class: %@", [m_lineBoxField cell]);
one gets:
2002-07-21 02:20:26.065 Unicode Font Info[442] cell class: LineBoxFieldCell
2002-07-21 02:20:26.108 Unicode Font Info[442] cell class:
<NSTextFieldCell: 0x2156e0>
Further reading of the list archives indicates this is the expected
result.... IB encodes the id of the NSTextFieldCell it knows about in
the .nib when you save it.
So is it even possible to change the cell in an NSTextField - or indeed
any single cell control - and use it in interface builder?
What if I add my custom class to the IB pallete somehow. I understand
that can be done, though I've no idea how.
--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
(see you later space cowboy ...)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.