[Re-post] Cell selection and scrolling
[Re-post] Cell selection and scrolling
- Subject: [Re-post] Cell selection and scrolling
- From: Eric Long <email@hidden>
- Date: Mon, 08 Nov 2004 09:34:35 -0800
[Reposted since there was no response over the weekend to the original post]
Hi,
I consider myself to be pretty green with Cocoa, as yet, so bear with me, as
I am in a continual learning mode.
I'm working on an outline view that contains parent items that are
"categories" and child items that represent files in the file system. When
a parent item is selected, I want to select all the child items
automatically, but the parent itself does not become selected. I found that
easy enough to do. But I am running into a couple of problems.
I use this method to select the children:
- (void) selectAllChildResultItems:(ResultDisplayItem*)parentItem
extendSelection:(BOOL)extend deselect:(BOOL)unselect
{
if ([itemTable isItemExpanded:parentItem] && [parentItem children] &&
[[parentItem children] count])
{
ResultDisplayItem *childItem;
NSMutableIndexSet *childRows = [NSMutableIndexSet indexSet];
NSEnumerator *iter = [[parentItem children]
objectEnumerator];
while (childItem = [iter nextObject])
{
if (unselect == NO)
[childRows addIndex:[itemTable rowForItem:childItem]];
else
[itemTable deselectRow:[itemTable rowForItem:childItem]];
}
if (unselect == NO)
[itemTable selectRowIndexes:childRows
byExtendingSelection:extend];
}
}
The first problem is that when the children are selected, the view is being
automatically scrolled to bring the last row selected into view. I don't
want that to happen in this case. I could perhaps hack it by intercepting
scrollRollToVisible in the table class, but this is an exceptional case.
I'd have to set a flag to indicate when to and when not to disable
scrolling. That seems like a long way to go for this.
Q. Isn't there a better way to select cells without the table scrolling
them into view automatically?
Also, in the above method, you'll notice that it may also be used to
deselect all child items. That option, however, is not working. It looks
like it should during execution, but the cells are never deselected.
Q. Can anyone tell me why this doesn't work for deselecting cells?
And lastly...
I'm wondering how efficient the rowForItem method is and how expensive this
might be if the number of items in the table is huge.
Q. Is there a more efficient way to handle this?
Thanks for the help,
Eric
_______________________________________________
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