One more try - NSCollectionView multi-selection problem..

  • Hi Everyone,

    In a previous posting, I had a problem with NSCollectionView not selecting a range of objects, when shift-selecting items.
    For example, if I were to click on object "3" and then shift-click on object "5", I would expect a range of 3,4,5 to be highlighted.
    Instead only 3 and 5 are selected.

    Ok, so multi-selection works. Sorta..

    (BTW, this same behavior happens with Imagebrowser sample app from Apple.)

    I added an observer to my NSArrayController's "selectionIndexes" to see what it think is happening.
    Sure enough, the NSArrayController is getting a bunch of ranges that look like this:

    <NSIndexSet: 0x100648650>[number of indexes: 2 (in 2 ranges), indexes: (2 4)]

    I would have expected something like this:
    <NSIndexSet: 0x100362a50>[number of indexes: 3 (in 1 ranges), indexes: (2-4)]

    Suggestions?
    I see a "setSelectionIndexes:" selector in the NSCollectionView object.
    Do I need to do something here? It seems like a huge headache to "teach" NSCollectionView to do a properly shift-selection of a range.

    Thanks!

    bob.
  • I believe for icon-type views, the idea that shift-selecting selects a range of items is no longer considered best practice these days. For example, the icon view in the Finder doesn't do that (list view does).

    command-click and shift-click are the same thing for icon views, i.e. they toggle the clicked item.

    --Graham

    On 09/07/2012, at 5:34 PM, Robert Monaghan wrote:

    > Hi Everyone,
    >
    > In a previous posting, I had a problem with NSCollectionView not selecting a range of objects, when shift-selecting items.
    > For example, if I were to click on object "3" and then shift-click on object "5", I would expect a range of 3,4,5 to be highlighted.
    > Instead only 3 and 5 are selected.
    >
    > Ok, so multi-selection works. Sorta..
    >
    > (BTW, this same behavior happens with Imagebrowser sample app from Apple.)
    >
    > I added an observer to my NSArrayController's "selectionIndexes" to see what it think is happening.
    > Sure enough, the NSArrayController is getting a bunch of ranges that look like this:
    >
    > <NSIndexSet: 0x100648650>[number of indexes: 2 (in 2 ranges), indexes: (2 4)]
    >
    > I would have expected something like this:
    > <NSIndexSet: 0x100362a50>[number of indexes: 3 (in 1 ranges), indexes: (2-4)]
    >
    > Suggestions?
    > I see a "setSelectionIndexes:" selector in the NSCollectionView object.
    > Do I need to do something here? It seems like a huge headache to "teach" NSCollectionView to do a properly shift-selection of a range.
  • Ok,

    So in the meantime, I have a bunch of customers filing bugs/feature requests to implement this ability..
    (Its a popular request, shall we say..)

    Is this something that can be overridden, turned on/off? Has anyone done this?

    Thanks!

    bob.

    On Jul 10, 2012, at 3:48 AM, Graham Cox wrote:

    > I believe for icon-type views, the idea that shift-selecting selects a range of items is no longer considered best practice these days. For example, the icon view in the Finder doesn't do that (list view does).
    >
    > command-click and shift-click are the same thing for icon views, i.e. they toggle the clicked item.
    >
    > --Graham
    >
    >
    >
    >
    >
    > On 09/07/2012, at 5:34 PM, Robert Monaghan wrote:
    >
    >> Hi Everyone,
    >>
    >> In a previous posting, I had a problem with NSCollectionView not selecting a range of objects, when shift-selecting items.
    >> For example, if I were to click on object "3" and then shift-click on object "5", I would expect a range of 3,4,5 to be highlighted.
    >> Instead only 3 and 5 are selected.
    >>
    >> Ok, so multi-selection works. Sorta..
    >>
    >> (BTW, this same behavior happens with Imagebrowser sample app from Apple.)
    >>
    >> I added an observer to my NSArrayController's "selectionIndexes" to see what it think is happening.
    >> Sure enough, the NSArrayController is getting a bunch of ranges that look like this:
    >>
    >> <NSIndexSet: 0x100648650>[number of indexes: 2 (in 2 ranges), indexes: (2 4)]
    >>
    >> I would have expected something like this:
    >> <NSIndexSet: 0x100362a50>[number of indexes: 3 (in 1 ranges), indexes: (2-4)]
    >>
    >> Suggestions?
    >> I see a "setSelectionIndexes:" selector in the NSCollectionView object.
    >> Do I need to do something here? It seems like a huge headache to "teach" NSCollectionView to do a properly shift-selection of a range.
    >
  • On 10/07/2012, at 4:37 PM, Robert Monaghan wrote:

    > Ok,
    >
    > So in the meantime, I have a bunch of customers filing bugs/feature requests to implement this ability..
    > (Its a popular request, shall we say..)
    >
    > Is this something that can be overridden, turned on/off? Has anyone done this?

    I haven't done it, but it should be easy enough.

    When the delegate is told that the selection has changed, check if the shift key is down for the current event,  grab the selection index and fill in the gaps. Then call -setSelectionIndexes:

    --Graham
  • On Jul 10, 2012, at 12:51 AM, Graham Cox wrote:

    >
    > On 10/07/2012, at 4:37 PM, Robert Monaghan wrote:
    >
    >> Ok,
    >>
    >> So in the meantime, I have a bunch of customers filing bugs/feature requests to implement this ability..
    >> (Its a popular request, shall we say..)
    >>
    >> Is this something that can be overridden, turned on/off? Has anyone done this?
    >
    >
    > I haven't done it, but it should be easy enough.
    >
    > When the delegate is told that the selection has changed, check if the shift key is down for the current event,  grab the selection index and fill in the gaps. Then call -setSelectionIndexes:

    Except that you're thinking about NSTableView--NSCollectionView doesn't have any delegate methods for selection semantics, that I know of. It sounds fragile to me but maybe this check could be done in -setSelectionIndexes: ?

    HTH,

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
previous month july 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today