macoscocoanscollectionview

How can I disable selection rectangle drawing in NSCollectionView?


I have an NSCollectionView up and running fairly nicely with an NSArrayController. My collection view items are configured to be multi-selectable and I am happy with the it. However, when a mouse drag event occurs within the collection view, a selection rectangle is drawn. How do I disable this selection rectangle drawing and still keep multiple selection in my NSCollectionView? Thanks for any help!


Solution

  • NSCollectionView is a fairly opaque class, there are not too many ways you can easily modify its fundamental behaviour.

    The drag actions appear to be handled by the private method _performDragFromMouseDown: rather than by overriding mouseDragged:. Exactly what the private method does I'm not sure.

    The simple answer is that you can't change the selection appearance except by modifying private methods of NSCollectionView.

    You may need to use a custom view instead of NSCollectionView if you must modify this behaviour.