Custom NSImageView
Custom NSImageView
- Subject: Custom NSImageView
- From: Livio Isaia <email@hidden>
- Date: Thu, 07 May 2009 17:16:38 +0200
I create MyImageView (from NSImageView) which must use MyImageCell (from
NSImageCell).
I put MyImageView in MyWindow with Interface Builder, creating an
NSImageView and setting its class to MyImageView.
In MyImageView.m I put:
@implementation MyImageCell
- (void)encodeWithCoder:(NSCoder *)aCoder {
[super encodeWithCoder:aCoder];
}
- (id)initWithCoder:(NSCoder *)decoder
{
if (self = [super initWithCoder:decoder])
{
...
}
return self;
}
...
@end
@implementation MyImageView
+ (void)initialize {
if (self == [MyImageView class]) {
[self setCellClass:[MyImageCell class]];
}
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[super encodeWithCoder:aCoder];
}
- (id)initWithCoder:(NSCoder *)decoder
{
if (self = [super initWithCoder:decoder])
{
[self setEnabled:YES];
[[self cell] setSelectable:YES];
[self setImageFrameStyle:NSImageFrameGrayBezel];
...
}
return self;
}
...
@end
Well: MyImageView is properly created, by its cell is still an
NSImageCell, and not MyImageCell.
Can you tell me why?
Besides if I call a public MyImageView's method with [NSApp
sendAction:@selector(anAction:) to nil] nothing happens ([NSApp
targetForAction:@selector(anAction:)] returns nil).
Why?
Thank you very much in advance,
best regards,
livio.
_______________________________________________
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