Re: Ensuring no selection in a table view
Re: Ensuring no selection in a table view
- Subject: Re: Ensuring no selection in a table view
- From: John Brownie <email@hidden>
- Date: Thu, 30 Dec 2010 13:03:24 +1000
On Thu Dec 30 2010 12:14:46 GMT+1000 (PGT) Kyle Sluder wrote:
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.
I think I understand that.
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.
This may be due to some interaction with the application being Carbon,
and this window alone being Cocoa.
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.
Yes, definitely redundant, trying to do the same thing multiple ways. I
tried subsets of them, but that didn't change the behaviour.
I hadn't picked up on setContent:, thinking that the binding to the data
source as the instance variable would do it, which brings to mind the
adage "assumptions are evil", and makes me wonder what other assumptions
I've made. So I put it in, and still no joy. I was wrong, though, in
thinking that it's the first item that is selected. Sometimes it's the
last, sometimes the first.
- (void)setStateStack:(NSArray *)newStack
{
[newStack retain];
[stateStack release];
stateStack = newStack;
[stateStackController setContent:stateStack];
NSArray *tempArray = [NSArray array];
[stateStackController setSelectedObjects:tempArray];
[tempArray release];
}
The same behaviour happens with or without the last three lines. I even
tried explicitly setting the selection to a particular row in that
method, but it seems to have no effect on the behaviour. I'm getting to
the point where I might just give up on solving it and move on to the
next thing.
[stateStackScroll setNeedsDisplay:YES];
This is unnecessary. Once the table view gets wind that its data has
been updated, it will call -setNeedsDisplayInRect: on itself.
That's nice, I hadn't realised that. Thanks for your input!
John
--
John Brownie, email@hidden or email@hidden
Summer Institute of Linguistics | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden