On Jul 20, 2012, at 9:36 PM, Quincey Morris wrote: > On Jul 20, 2012, at 19:03 , Keary Suska wrote: > >> In an NSTableView I am providing custom cells via >> tableView:dataCellForTableColumn:row:, based on values represented in other >> columns. The cell is usually determined when a value is specified via >> NSPopupButtonCells in two other columns. When an effecting value is changed, >> I call reloadDataForRowIndexes:columnIndexes: to refresh the cell(s) in >> question. The problem is that even thought the delegate method is properly >> called to return the changed NSCell, the NSTableView will not redraw the >> cell until the row is deselected or is refreshed by some other means--such >> as obscuring the tableview with another window or clicking in the cell (but >> only when it's data cell is editable). I have also tried calling >> setNeedsDisplayInRect:, but that doesn't work either. >> >> Oddly, it seems to work fine when called from an action method assigned to >> the NSMenuItems level of a particular NSPopupButtonCell, but not when called >> from an action method assigned to the NSPopupButtonCell itself. Although I >> did try to specify the action for the individual NSMenuItems in the other >> popup, but that didn't work either. The main difference between the two is >> that one is specified via Interface Builder and the other is generated in >> code. > >> - (IBAction)selectComparator:(id)sender >> { >> // clear operand >> [[self clauseExpressionForRow:[queryTableView selectedRow]] >> setOperand:[ClauseOperand nullOperand]]; >> >> // comparator changes may change operand displays >> [queryTableView reloadDataForRowIndexes:[NSIndexSet >> indexSetWithIndex:[queryTableView selectedRow]] columnIndexes:[NSIndexSet >> indexSetWithIndex:4]]; >> } > > So, to clarify, when it fails, are you saying: > > 1. It doesn't get to 'selectComparator:'.
No, it does. > 2. It gets there, but 'dataCellForTableColumn:' doesn't get called for column > 4 (at least, not until later, at the point where the row really redraws). NSLog shows that the delegate method *is* called, and the expected data cell is being returned for column 4. > 3. It gets to 'dataCellForTableColumn:' for the right row/column combinations > at the expected time, but the display just doesn't redraw. Exactly. > What happens if you simply 'reloadData' instead of trying to be specific, > and/or what happens if you simply 'setNeedsDisplay:' instead of trying to be > specific? I tried reloadData, to no effect. I just tried the setNeedsDisplay: and that didn't work either. > Also, I notice that if '[queryTableView selectedRow]' isn't what you are > expecting, when 'selectComparator:' is called, you'd get precisely the > behavior you describe. NSLogs show that it is returning expected values. I agree that it "feels" a little fragile but I don't know what other options I have--doing this in the setObjectValue delegate call seems even more fragile. Curiously, the following workaround works: Change reloadDataForRowIndexes to: [self performSelector:@selector(refreshCellAtRect:) withObject:[NSValue valueWithRect:[queryTableView frameOfCellAtColumn:4 row:[queryTableView selectedRow]]] afterDelay:0.0]; With: - (void)refreshCellAtRect:(NSValue *)rectValue; { [queryTableView setNeedsDisplayInRect:[rectValue rectValue]]; } So there must be something with redraw and the event loop. Anyway, this almost seems like a bug, but I wanted to be sure before I report it. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com