refresh of tableColumn headerView not working
refresh of tableColumn headerView not working
- Subject: refresh of tableColumn headerView not working
- From: "William Zumwalt" <email@hidden>
- Date: Sat, 30 Jun 2007 18:40:12 -0500
This problem is driving me nuts still ...
I've changed this problem up a bit to simplify it and it's strange. As soon
as I create these header cells, I'm always getting one more header than I
need, yet it's not a header, but appears to be one. It's like a ghost
header. It's just the text and not a control header cell than I can click on
like the others. I've inspected my createHeaders: method (below) as I run
the program and it's creating the proper number of headers and columns, yet
it's always adding the appearance of one extra even though the NSTableView
numberOfColumns returns the correct number of columns. It's like the
NSTableHeaderView is not being refreshed.
Here I've added all the code that creates my NSPopUpButtonCell's as headers
of each column and adding columns to the tableview. I see nothing wrong with
it. It all works fine with the exception of new popup selections not
refreshing the new title correctly, rather it just overlays new item
selection title text on top of old title text.
@interface DataTableController : NSObject
{
IBOutlet InputTableView *dataInputTable;
IBOutlet NetworkOutlineController *networkOutlineController;
DataTableHeader *dataTableHeader;
...
@implementation DataTableController
- (void) awakeFromNib
{
NSTableHeaderView *currentTableHeader = [dataInputTable headerView];
dataTableHeader = [[DataTableHeader alloc]
initWithController:networkOutlineController];
[dataTableHeader setFrame:[currentTableHeader frame]];
[dataTableHeader setBounds:[currentTableHeader bounds]];
[dataTableHeader setTableView:dataInputTable];
[dataInputTable setHeaderView:dataTableHeader];
return;
}
/*
* This is where new headers are created and added to columns
* which are then added to the table
*/
- (void) createHeaders:(NSArray *) columnItems
{
BOOL debug = YES;
//DataTableHeaderCell *headerCell;
NSPopUpButtonCell *headerCell;
NSTableColumn *column;
if (debug) {
NSLog(@"columnItems count %d", [columnItems count]);
}
for (int i = 0; i < [columnItems count]; i++) {
NSString *columnName = [columnItems objectAtIndex:i];
//headerCell = [[DataTableHeaderCell alloc] initTextCell:columnName];
headerCell = [[NSPopUpButtonCell alloc] initTextCell:columnName];
[headerCell setPullsDown:NO];
[headerCell setControlSize:NSMiniControlSize];
[headerCell setBordered:NO];
[headerCell setFont:[NSFont labelFontOfSize:
[NSFont smallSystemFontSize]]];
[headerCell setEditable:YES];
[headerCell addItemWithTitle:@"Item A"];
[headerCell addItemWithTitle:@"Item B"];
[headerCell addItemWithTitle:@"Item C"];
column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]];
[column setHeaderCell:headerCell];
[column setTableView:dataInputTable];
[dataInputTable addTableColumn:column];
if (debug) {
NSLog(@"creating header %d, %@", i, columnName);
NSLog(@"column count %d", [dataInputTable numberOfColumns]);
}
}
[[dataInputTable headerView] setNeedsDisplay:YES];
return;
}
@interface DataTableHeader : NSTableHeaderView
{
...
}
@implementation DataTableHeader
/*
* When user clicks on a header popup cell, the selected item should be the
* new column header.
*/
- (void) mouseDown:(NSEvent *) event
{
NSPoint point = [event locationInWindow];
int index = [self columnAtPoint:[self convertPoint:point fromView:nil]];
if (index >= 0) {
NSTableColumn *column = [[[self tableView] tableColumns]
objectAtIndex:index];
[[column headerCell] trackMouse:event
inRect:[self headerRectOfColumn:index]
ofView:self untilMouseUp:NO];
[[column headerCell] setTitle:[[[column headerCell] selectedItem] title]];
[self updateOutlineModel:column];
//[self displayRect:[self headerRectOfColumn:index]];
} else {
[super mouseDown:event];
}
[self setNeedsDisplay:YES];
return;
}
_______________________________________________
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