On Wed, Dec 29, 2010 at 5:11 PM, John Brownie <john_brow...@sil.org> wrote: > On Thu Dec 30 2010 09:56:18 GMT+1000 (PGT) Kyle Sluder wrote: > >> Is it propagating the selection from the controller? IOW, just because >> you have set avoidsEmptySelection=NO doesn't mean the controller will >> *prefer* an empty selection. > > I don't understand this. How does the controller propagate a selection? How > does it get a selection in the first place? Do I need to use something like > setSelectedObjects: for the controller with an empty array? (Tried that, > didn't change anything.)
Instances of NSArrayController expose a selectedObjects property. If all of its columns are bound to the same NSArrayController, NSTableView autobinds its selection binding to the controller's selectedObjects property. This is what makes zero-code binding-based interfaces possible. > Just to be clear, whenever the window is shown, I set the contents of the > array to be correct for the current context. I used deselectAll: in the > routine that set the array, but it didn't seem to have any effect. I created a new demo project and wasn't able to reproduce this behavior. With avoidsEmptySelection=YES, calling -setContent: on the array controller causes its selection to change as the window is constructed. If I set avoidsEmptySelection=NO in IB, then this doesn't happen. > > - (void)setStateStack:(NSArray *)newStack > { > [newStack retain]; > [stateStack release]; > stateStack = newStack; > [stateStackTable deselectAll:self]; > NSArray *tempArray = [NSArray array]; > [stateStackController setSelectedObjects:tempArray]; > [tempArray release]; This is redundant, as I'm sure you're aware. But more importantly, how are you notifying the controller of its new content? I see no call to -setContent: here. > [stateStackScroll setNeedsDisplay:YES]; This is unnecessary. Once the table view gets wind that its data has been updated, it will call -setNeedsDisplayInRect: on itself. --Kyle Sluder _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com