Selections in NSCollectionView

  • I'm trying to use NSCollectionView, and I want to provide visual
    feedback for the selected item(s) in the collection.  The collection
    view is set to be selectable, and I can find out the selected indexes
    just by asking it.

    Getting from there to the selected NSViews, I get stuck.  I thought
    maybe I could ask the NSCollectionView for its subviews and go from
    there, but the -subviews array isn't sorted to match the selected
    indexes (I know it's not documented to be that way but I didn't know
    what else to try).  My NSView subclass can indicate that it's
    selected, I just can't figure out how to tell the appropriate views
    that they should do this.

    --
    Tom Harrington
    <atomicbird...>
    AIM: atomicbird1
  • Have you looked at NSCollectionView's -content method?

    On Nov 27, 2007, at 23:49, Tom Harrington wrote:

    > I'm trying to use NSCollectionView, and I want to provide visual
    > feedback for the selected item(s) in the collection.  The collection
    > view is set to be selectable, and I can find out the selected indexes
    > just by asking it.
    >
    > Getting from there to the selected NSViews, I get stuck.  I thought
    > maybe I could ask the NSCollectionView for its subviews and go from
    > there, but the -subviews array isn't sorted to match the selected
    > indexes (I know it's not documented to be that way but I didn't know
    > what else to try).  My NSView subclass can indicate that it's
    > selected, I just can't figure out how to tell the appropriate views
    > that they should do this.
    >
    > --
    > Tom Harrington
    > <atomicbird...>
    > AIM: atomicbird1
    >
    >
  • > I'm trying to use NSCollectionView, and I want to provide visual
    > feedback for the selected item(s) in the collection. The collection
    > view is set to be selectable, and I can find out the selected
    > indexes just by asking it.
    >
    > Getting from there to the selected NSViews, I get stuck. I thought
    > maybe I could ask the NSCollectionView for its subviews and go from
    > there, but the -subviews array isn't sorted to match the selected
    > indexes (I know it's not documented to be that way but I didn't know
    > what else to try). My NSView subclass can indicate that it's
    > selected, I just can't figure out how to tell the appropriate views
    > that they should do this.
    >
    > -- Tom Harrington
    > <email...>
    > AIM: atomicbird1

    Suppose you have a prototype (NSCollectionViewItem) and it's
    associated prototypeView (custom view).
    Using bindings programmatically, you can bind a property of the
    prototypeView to the "selected" property of it's prototype. Then use
    this property to decide when to draw the selection in the prototypeView.
  • On 11/28/07, Ingvar Nedrebo <in.cocoadev...> wrote:
    > Have you looked at NSCollectionView's -content method?

    I have.  It gives me an array of model objects (via the
    NSArrayController I have bound to the collection view's content
    binding).  That's useful, but in this case I need to get to my view
    objects.

    > On Nov 27, 2007, at 23:49, Tom Harrington wrote:
    >
    >> I'm trying to use NSCollectionView, and I want to provide visual
    >> feedback for the selected item(s) in the collection.  The collection
    >> view is set to be selectable, and I can find out the selected indexes
    >> just by asking it.
    >>
    >> Getting from there to the selected NSViews, I get stuck.  I thought
    >> maybe I could ask the NSCollectionView for its subviews and go from
    >> there, but the -subviews array isn't sorted to match the selected
    >> indexes (I know it's not documented to be that way but I didn't know
    >> what else to try).  My NSView subclass can indicate that it's
    >> selected, I just can't figure out how to tell the appropriate views
    >> that they should do this.
    >>
    >> --
    >> Tom Harrington
    >> <atomicbird...>
    >> AIM: atomicbird1
    >>
    >>
    >
    >

    --
    Tom Harrington
    <atomicbird...>
    AIM: atomicbird1
  • On 11/28/07, <public.web...> <public.web...> wrote:
    >> I'm trying to use NSCollectionView, and I want to provide visual
    >> feedback for the selected item(s) in the collection. The collection
    >> view is set to be selectable, and I can find out the selected
    >> indexes just by asking it.
    >>
    >> Getting from there to the selected NSViews, I get stuck. I thought
    >> maybe I could ask the NSCollectionView for its subviews and go from
    >> there, but the -subviews array isn't sorted to match the selected
    >> indexes (I know it's not documented to be that way but I didn't know
    >> what else to try). My NSView subclass can indicate that it's
    >> selected, I just can't figure out how to tell the appropriate views
    >> that they should do this.
    >
    > Suppose you have a prototype (NSCollectionViewItem) and it's
    > associated prototypeView (custom view).
    > Using bindings programmatically, you can bind a property of the
    > prototypeView to the "selected" property of it's prototype. Then use
    > this property to decide when to draw the selection in the prototypeView.

    Thanks, that does the trick nicely.  It's also possible to set this up
    in IB, if the property is exposed as a binding.

    --
    Tom Harrington
    <atomicbird...>
    AIM: atomicbird1
previous month november 2007 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    
Go to today