Thanks Todd. I tried it out but am still getting the normal size checkboxes. Do you see the error in this snippet?
NSRect frameRect = [self bounds], checkboxRect;
checkboxRect = NSMakeRect(frameRect.origin.x + 8, frameRect.origin.y + 8, 20, 20);
NSButton *checkButton = [[NSButton alloc] initWithFrame: checkboxRect]; NSButtonCell *checkCell = [[NSButtonCell alloc] init];
[checkCell setButtonType: NSSwitchButton]; [checkCell setState: NSOnState]; [checkButton setCell: checkCell]; [self addSubview: checkButton];
Ken On May 2, 2005, at 10:42 PM, Todd Yandell wrote: Hi,
You could do either of the two things you mentioned.
If you want to change the size of an NSButton control, try something along these lines: [[yourButton cell] setControlSize:NSSmallControlSize];
If you want to add an NSCell subclass to an NSView, then you will need a "host" view. NSCell doesn't provide any of the NSView methods on it's own, instead it requires another view (like NSButton, for instance) to provide all of the NSView-compatible methods for it. This helps keep NSCell instances more light-weight so they can be used over and over without all of the overhead of an NSView. So, you can either add it directly to an instance of NSControl/NSButton (setCell:), or add it to an NSMatrix or another similar class.
Hope that helps! Todd Yandell |