Re: NSTableView custom class
Re: NSTableView custom class
- Subject: Re: NSTableView custom class
- From: Oscar Bascara <email@hidden>
- Date: Sun, 22 Jul 2001 10:27:22 -0700
Well, it works now after some experimentation, and here's a follow-up.
In PB, I incorrectly picked CustomView from the palette (and then
specified my NSTableView subclass as the custom class). This meant I
would have to override the initWithFrame: method, as I tried to below.
What I needed to do was pick the NSTableView from the palette directly,
and along with it I get NSScrollView. It would probably be hard to get
an NSTableView from a CustomView.
In creating custom classes, when do I choose CustomView and when do I
choose the superclass itself from the palette? Sometimes it seems I
have to do it one way and sometimes the other way. In this case, I had
to choose the superclass. When I was customizing NSSlider, I had to
choose CustomView. Also, in the Learning Cocoa project called ToDo,
with customizing NSMatrix, CustomView is picked for creating
NSCalendarMatrix and NSMatrix (which I can't actually find on the
palette, how did they select it) is picked for creating
SelectionNotifyMatrix.
Oscar
On Sunday, July 22, 2001, at 12:43 AM, Oscar Bascara wrote:
I'm trying to subclass NSTableView but the scroll bars never show up
with the rows eventually going off the window frame. Also the rows
grow from bottom to top instead of top to bottom. What's incorrect
with my initWithFrame: method for the subclass? I'm pretty sure I'm
missing stuff. For example, how do I even access the underlying
NSScrollView to set vertical scroll bars?
- (id)initWithFrame:(NSRect)frameRect
{
if (self = [super initWithFrame:frameRect]) {
[self setAllowsEmptySelection:NO];
[self setAllowsMultipleSelection:NO];
[self setAllowsColumnSelection:NO];
[self setDrawsGrid:YES];
[self setRowHeight:15.0];
tableColumn = [[NSTableColumn alloc]
initWithIdentifier:@"name"];
[self addTableColumn:tableColumn];
[self sizeLastColumnToFit];
}
return self;
}
Oscar