Re: SelectedRowIndexes
Re: SelectedRowIndexes
- Subject: Re: SelectedRowIndexes
- From: "gMail.com" <email@hidden>
- Date: Fri, 16 Oct 2009 11:21:02 +0200
- Thread-topic: SelectedRowIndexes
Thank you I.S.
This is what I am doing. Overriding the tableView APIs and keeping trace of
the selection through my array.
> You're going to have to track changes in selection yourself
> (examine the NSTableView API - there are methods to help you with this).
Since I have noticed that even
selectRow:(int)rowIndex byExtendingSelection:(BOOL)flag
gets invoked with a sorted index (like 0, 1, 2...) in case of multiple
selection, I guess I have to override mouseDown and keyDown to invoke
selectRow by myself passing the sorted and right sequence of indexes.
If you meant some other specific API, please let me know which one.
> 1 - Click the third row, shift-click the seventh row. Now the
> selection index set is now {2, 3, 4, 5, 6}.
Ok, this is equal to my selection sort order
> 2 - With that last result, command-click row 3, then, 4, then 3 again.
> The selection set is now {2, 3, 5, 6}.
command-click row 3 -> now my selection is {3, 4, 5, 6}
command-click row 4 -> now my selection is {4, 5, 6}
command-click row 3 -> now my selection is {4, 5, 6, 3}
> 3 - Click row 7 shift-click row 6, then Cmd-click row 8. Selection is
> now {5, 6, 7}.
click row 7 -> now my selection is {6}
shift-click row 6 -> now my selection is {6, 5}
command-click row 8 -> now my selection is {6, 5, 7}
It makes sense.
:-D
--
L.L.
> Da: "I. Savant" <email@hidden>
> Data: Wed, 14 Oct 2009 12:11:39 -0400
> A: "gMail.com" <email@hidden>
> Cc: <email@hidden>
> Oggetto: Re: SelectedRowIndexes
>
> On Oct 14, 2009, at 11:55 AM, gMail.com wrote:
>
> Oh, come on, at least pick a witty pseudonym. :-D
>
>
>> when I call [tableView selectedRowIndexes];
>> I always get a indexSet already sorted by row.
>> Instead I need to sort it as the selection order.
>> I mean, if the user selected the rows in the order
>>
>> Row 6
>> Row 2
>> Row 8
>>
>> I want to get 6, 2, 8 and not 2, 6, 8 as I get now with
>> selectedRowIndexes.
>> How can I do that?
>
> You can't. Not with -selectedRowIndexes. As you said, it returns an
> NSIndexSet. Sets are unordered by nature. Not in the sense you're
> looking for. They're kept internally as an ascending-order list for
> efficiency.
>
>
> Also consider a few scenarios that will affect "the selection order":
>
> 1 - Click the third row, shift-click the seventh row. Now the
> selection index set is now {2, 3, 4, 5, 6}.
>
> 2 - With that last result, command-click row 3, then, 4, then 3 again.
> The selection set is now {2, 3, 5, 6}.
>
> 3 - Click row 7, shift-click row 6, then Cmd-click row 8. Selection is
> now {5, 6, 7}.
>
> Considering these scenarios, what would your selection order be in
> each? What about combining them? Selection can go in many directions
> and things can be added and removed to/from anywhere in the set. Think
> carefully - getting this basic behavior wrong has the potential to
> annoy users.
>
>
>> Please note that I can select the rows even programmatically,
>> because the
>> user selects an object on the canvas.
>
> Same as above - you'll have to track the order. I'd make a table
> view subclass and override (calling super, then my custom code) the
> selection-changing methods, then provide a separate selection-getting
> routine (to provide an ordered array of indexes) called
> "orderedSelection" or something similar. This gives you one central
> place for user- or code-initiated selection changes.
>
> --
> I.S.
>
>
_______________________________________________
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