Re: Selections and NSCollectionView

  • I've read this thread:

    http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg02158.html

    but I can't figure out how to do it. I've exposed bindings, called
    bind:..., tried and observer, and my selected property in my view
    doesn't get set. Could somebody please post some sample code.

    Thanks,

    Rod Schmidt
  • On Dec 30, 2007 6:04 PM, Rod Schmidt <rschmidt...> wrote:
    > I've read this thread:
    >
    > http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg02158.html
    >
    > but I can't figure out how to do it. I've exposed bindings, called
    > bind:..., tried and observer, and my selected property in my view
    > doesn't get set. Could somebody please post some sample code.

    To give visual feedback of selection, I added an NSBox behind (but not
    containing) the other elements in the view that the collection view
    item is using.  In IB, I bound the NSBox's "hidden" property to the
    collection view item's "selected" key (with a boolean negation value
    transformer).  That gives me simple visual feedback of the selected
    item-- the NSBox is only visible when the view is selected, and I can
    configure the NSBox's appearance as needed.  I didn't have to expose
    any bindings because NSBox already exposes the one I needed.

    To get notification of selection changes-- the collection view's
    "selection indexes" binding is bound to the selectionIndexes key of
    the array controller I'm using to manage the content.  In my app
    controller class I observe changes on this key in the array
    controller.  Then I can ask the array controller for its
    currently-selected indexes to get the appropriate model objects.

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