• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
refresh of tableColumn headerView not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: NSFileWrapper Store Type
  • Next by Date: Re: Set background color to NSToolbar
  • Previous by thread: Re: KVO persists too long
  • Next by thread: Astoundingly dumb bindings question
  • Index(es):
    • Date
    • Thread