 |
|
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
Wizumwalt@gmail.com Guest
 |
Posted: Mon Jul 02, 2007 10:16 pm Post subject: NSPopUpButtonCell or it's view won't refresh |
 |
|
This problem is driving me nuts and I have yet to understand what's wrong with it.
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/text only after the last column. 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. Another side affect of this problem is that when I make a selection on the NSPopUpButtonCell menu items, the new selection just overlays the old text (the old header title), so it's text on top of text and makes it unreadable.
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 exceptions above.
Also in this problem, I've subclassed NSPopUpButtonCell and am wondering why drawInteriorWithFrame: is getting called 5 times, because that's how many titles headers I see in my view, although I have only created four.
@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];
[[excludedDataPatterns alloc] init];
return;
}
/*
* This is how I create my NSPopUpButtonCell headers on the fly. My * table initially starts out w/ no headers. Once the user opens up a * file, then I create then according to the file being parsed. */
- (void) createHeaders:(NSArray *) columnItems {
DataTableHeaderCell *tableHeaderCell;
NSTableColumn *column;
for (int i = 0; i < [columnItems count]; i++) { NSString *columnName = [columnItems objectAtIndex:i];
tableHeaderCell = [[DataTableHeaderCell alloc] initTextCell:columnName];
[tableHeaderCell setPullsDown:NO];
[tableHeaderCell setControlSize:NSMiniControlSize]; [tableHeaderCell setBordered:NO];
[tableHeaderCell setFont:[NSFont labelFontOfSize: [NSFont smallSystemFontSize]]];
if (i == 0) {
[tableHeaderCell setEditable:NO];
column = [[DataTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]]; }
else {
[tableHeaderCell setEditable:YES];
[tableHeaderCell addItemWithTitle:@"Item A"]; [tableHeaderCell addItemWithTitle:@"Item B"]; [tableHeaderCell addItemWithTitle:@"Item C"];
column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]]; }
[column setHeaderCell:tableHeaderCell];
[column setTableView:dataInputTable];
[dataInputTable addTableColumn:column];
[tableHeaderCell release];
}
[[dataInputTable headerView] setNeedsDisplay:YES];
return;
}
@implementation DataTableHeader
/*
* This is where I catch the user clicking on the menu item of the * popup, but the problem is that when the selection is made, the * new text item just overlays the old text and makes it unreadable. */
- (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 displayRect:[self headerRectOfColumn:index]]; }
/*else {
[super mouseDown:event];
}*/
[self setNeedsDisplay:YES];
return;
}
/*
* Not much going on here, just showing that this is my NSPopUpButtonCell class that I use.
*/
@interface DataTableHeaderCell : NSPopUpButtonCell {
}
- (id) init;
- (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView;
@end
@implementation DataTableHeaderCell
....
- (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
[super drawInteriorWithFrame:cellFrame inView:controlView]; NSLog(@"controlView %@", [controlView className]); NSLog(@"title = %@", [self title]);
//[controlView displayIfNeededInRect:cellFrame]; //[controlView setNeedsDisplay:YES];
//[controlView headerRectOfColumn:
return;
} |
|
| |
|
|
|
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|