NSCell subclass
NSCell subclass
- Subject: NSCell subclass
- From: Greg Hulands <email@hidden>
- Date: Sat, 13 Jul 2002 12:57:46 +1000
Hi,
I am trying to make an NSCell subclass that contains a text field cell and a
button cell to the right of the text field.
The header is:
@interface BuilderCell : NSCell
{
NSButtonCell *_remove;
NSTextFieldCell *_text;
BuilderView *_view;
}
- (void)setView:(BuilderView *)view;
- (BuilderView *)view;
@end
And the implementation:
@implementation QualifierBuilderCell
- (id)initTextCell:(NSString *)aString
{
[super initTextCell:aString];
_text = [[NSTextFieldCell alloc] initTextCell:@""];
[_text setBackgroundColor:[NSColor whiteColor]];
_remove = [[NSButtonCell alloc] initTextCell:@"-"];
[_remove setBezelStyle:NSCircularBezelStyle];
[_remove setButtonType:NSMomentaryPushInButton];
[_remove setTarget:self];
[_remove setAction:@selector(remove:)];
return self;
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
int btnWidth = 39;
int btnGap = 5;
float textWidth = cellFrame.size.width - btnWidth - btnGap;
NSPoint o = cellFrame.origin;
NSRect textRect = NSMakeRect(o.x, o.y, textWidth, 22);
NSRect btnRect = NSMakeRect(o.x + textWidth + btnGap, o.y, 38, 38);
[_text drawWithFrame:textRect inView:controlView];
[_remove drawWithFrame:btnRect inView:controlView];
}
- (void)remove:(id)sender
{
[[self view] removeCell:self];
}
- (void)setView:(BuilderView *)view
{
[_view autorelease];
_view = [view retain];
}
- (BuilderView *)view
{
return _view;
}
@end
Question.
Only the button cell seems to display. When trying to click the button, it
does not respond to the click. Do I need to some how manage the mouse events
of my cell and the pass them on to each cell within mine?
Does anyone know of source code floating around of an NSCell subclass that
contains two or more other cells?
Any help is greatly appreciated.
Regards,
Greg
_______________________________________________
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.