NSTableView Redraw Weirdness
NSTableView Redraw Weirdness
- Subject: NSTableView Redraw Weirdness
- From: "G. 'Andrew' Tapolow" <email@hidden>
- Date: Sun, 24 Jun 2001 10:41:08 -0700
Allo, all.
I've managed to completely implement an NSTableView. It has 5 columns. 2
Image, 1 text, 2 NSCheckBox. I've also been able to eliminate the header
row and place an NSImage above it..
The weirdness comes from the fact that clicking to switch to the upper
row(s) will cause the row to blank as I am maintaining a mouseDown.
This doesn't happen when I switch from row 3 (or beneath) to any of the
rows. However, switching from row 2 to row 1 causes the date in both
rows to blank out (widgets, items, and images disappear). Row one still
highlights (and in a side note: I'd still love to know how to get a
table to not highlight the selected row).
Dragging over the row (without changing rows) causes the widgets to
reappear as the mouse is dragged over them. Dragging to the other row,
causes the widgets to once again appear. Unless... If I'm in row
2..Dragging to row 1 is as noted above. If I'm in row 2 and drag down to
3...all of 2 redraws itself and becomes visible.
From a technical point of view:
IB Side of the World:
The NSTableView in IB is set with all the "Allows" selections off and
only a vertical scroll bar; It 'Shows Grid' and 'Allows Resizing'. (I'm
not exactly sure what "Shows Grid" is for. 'Display Column Headers' is
off. None of the columns should be editable. I've moved the NSImage
above the header-less NSTableView away from it to give the NSTableView
"breathing room" sometimes it seems to help sometimes it doesn't.
Preferably, they should be touching. I've also tried to move the
NSTableView to the Front, to the back. This doesn't seem to affect the
redraw area, too.
PB side of the world:
The delegate is a View Controller (I'll describe in a moment) and the
target is a "HitListArea:" action in the Controller
The Controller implements the following:
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn row:(int)row;
Used to set the value and state of the checkboxes and the data for
the NSImage
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row;
Set depending on data for rows that are locked out from the user
- (BOOL)tableView:(NSTableView *)tableView
shouldSelectTableColumn:(NSTableColumn *)tableColumn;
The image and text columns are set to NO. This doesn't prevent the
user from being able to select a row by clicking in those columns.
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
Returns the NSString for the text columns, the NSImage for those
columns, and an NSButton for those columns
- (IBAction)hitListArea:(id)sender;
Sends [TableViewInst reloadData]. This has helped redraw the
vanished widgets from the original state which was far worse.
final commentary:
I guess in a perfect world the table wouldn't highlight. Clicks on the
table would be immediately handed off to the columns where the
checkboxes were. The checkboxes would do their standard GUI and send a
message to my controller which would update the data. There would be no
redraw on a mouse click in the view except for the NSCheckbox.
So, after 2 weeks of poking and prodding I've returned to the list to
say "Ahhhhhgh!" Any pointers on this issue would be greatly
appreciated...I'm at wits end.
-G. 'Andrew' Tapolow
Sr. Software Eng.
(In fear of demotion to Jr. Installer builder)