redrawing an NSPopUpButtonCell, and ghost effect
redrawing an NSPopUpButtonCell, and ghost effect
- Subject: redrawing an NSPopUpButtonCell, and ghost effect
- From: "Ender Wiggins" <email@hidden>
- Date: Thu, 10 Aug 2006 21:01:57 -0500
I have a new problem by putting an NSPopUpButtonCell within my tables
headers by subclassing NSTableHeaderView.
#1 If I setBordered:NO on the NSPopUpButtonCell, then once I select
the button by pressing mouse down, the cell seems to draw the newly
selected item text on top of the previous item text without clearing
it first. If I set it to YES, then it displays the new selection
within the cell just fine, but of course, shows the border that I
don't want.
One thing to note here is that, if I tab over to another NSView, and
then click on a tab which brings this tabbed pane back up, the
NSTableView headers are redisplayed correctly and cleanly. I tried
setNeedsDisplay, but that didn't do anything to it.
#2 The other problem is that the NSTableHeaderView has 4 columns, but
shows a 5th column as well, like a ghost effect of what's in the 4th.
If I select the mouseDown on the 5th column, my mouseDown debug output
displays a -1 for that column (like it doesn't exist, but it shows
up), but clicking on the other 4 columns show output correctly from 0
to 3. Clicking on other tab buttons and coming back to this
NSTableView screen don't clear out the 5th column problem.
Here is how my popup button cells are created in the columns.
[code]
NSString *col = [columnItems objectAtIndex:i];
headerCell = [[NSPopUpButtonCell alloc] initTextCell:col];
[headerCell setPullsDown:NO];
[headerCell setControlSize:NSMiniControlSize];
[headerCell setBordered:YES];
[headerCell setEditable:YES];
[headerCell setControlView:[tableView headerView]];
[headerCell setFont:[NSFont labelFontOfSize:
[NSFont smallSystemFontSize]]];
[headerCell addItemWithTitle:@"Item A"];
[headerCell addItemWithTitle:@"Item B"];
[headerCell addItemWithTitle:@"Item C"];
column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]];
[column setHeaderCell:headerCell];
[headerCell release];
[tableView addTableColumn:column];
[column release];
[/code]
This is my class subclassed from NSTableHeaderView, mouseDown method.
[code]
- (void)mouseDown:(NSEvent *)event
{
NSPoint point = [event locationInWindow];
int column = [self columnAtPoint:[self convertPoint:point fromView:nil]];
NSLog(@"column: %d", column);
if (column >= 0) {
NSTableColumn *col = [[[self tableView] tableColumns]
objectAtIndex:column];
[[col headerCell] trackMouse:event
inRect:[self headerRectOfColumn:column]
ofView:self untilMouseUp:NO];
NSLog(@"selected %@", [[[col headerCell] selectedItem] title]);
[[col headerCell] setTitle:[[[col headerCell] selectedItem] title]];
[self setNeedsDisplay:YES];
} else {
[super mouseDown:event];
}
}
[/code]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden