I'm still trying to make NSPopUpButtonCell's appear in my
NSTableViewHeader. The title of my first popup item appears, but it
has a few problems.
#1 Clicking on the header doesn't drop down the items. Though I do get
the mouseDown event from overriding my NSTableHeaderView.
#2 I can't drag on the edges of the column to resize them.
#3 I have four columns and four headers (which I see during debug),
although there are 5 headers that appear but it's the 4th that looks
like it's being shown twice and not refreshed.
I subclassed NSTableHeaderView and add it to my NSTableView here.
- (void) awakeFromNib
{
NSTableHeaderView *currentTableHeader = [tableView headerView];
DataTableHeader *dataTableHeader = [[DataTableHeader alloc] init];
[dataTableHeader setFrame:[currentTableHeader frame]];
[dataTableHeader setBounds:[currentTableHeader bounds]];
[tableView setHeaderView:dataTableHeader];
}
I think at this point I have something wrong, this is where I create
my table column headers but I don't know how to put the
NSPopUpButtonCell's into my NSTableHeaderView. Below they are just put
directly into the NSTableView by doing a setHeaderCell.
- (int) createColumns
{
NSTableColumn *column;
NSPopUpButtonCell *headerCell;
...
for (int i = 0; i < count; i++) {
NSString *col = [columnItems objectAtIndex:i];
headerCell = [[NSPopUpButtonCell alloc] initTextCell:col];
[headerCell setControlSize:NSMiniControlSize];
[headerCell setBordered:NO];
[headerCell setPullsDown:YES];
[headerCell setFont:[NSFont labelFontOfSize:
[NSFont systemFontSize]]];
[headerCell addItemWithTitle:@"Item A"];
[headerCell addItemWithTitle:@"Item B"];
column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]];
[column setHeaderCell:headerCell];
[column sizeToFit];
[tableView addTableColumn:column];
}
...
}
Don't really know what needs to be added here. But I do get mouse down events.
@implementation DataTableHeader
- (void)mouseDown:(NSEvent *)theEvent
{
NSLog(@"mouseDown event");
}
@end
Anyone know how to get the NSPopUpButtonCell into the table headers if
what I've got is on the right track?