Hi everyone,
I have recently discovered the joys of NSCollectionView, and have a couple of questions about it.
First of all, is there a way to control how far apart the different views within the collection view are spaced? By default they are crammed together, and short of making each individual view have a transparent padding area, I don't know how to space them apart.
Also, what is the best way to notify the view that it is selected when a user clicks on it? Currently in my modal class I have an "isSelected" boolean variable declared. I have bound my collection view to an array controller named "billsArrayController", and have set up KVO in my controller class to listen for changes to the "selectionIndexes" property. When the selection is changed, I do this:
I can then bind the UI controls to the isSelected property to turn them on and off when a bill is selected. However, recording this in the data model just doesn't feel right, and I assume there must be a better way to notify views when their represented object is selected.
Whilst typing this I thought of the idea of overriding the NSResponder becomeFirstResponder and resignFirstResponder methods in my view subclass to alter the view appearance to show selection; would this be a good way to do it?
As always, thanks in advance for any help .
I have recently discovered the joys of NSCollectionView, and have a couple of questions about it.
First of all, is there a way to control how far apart the different views within the collection view are spaced? By default they are crammed together, and short of making each individual view have a transparent padding area, I don't know how to space them apart.
Also, what is the best way to notify the view that it is selected when a user clicks on it? Currently in my modal class I have an "isSelected" boolean variable declared. I have bound my collection view to an array controller named "billsArrayController", and have set up KVO in my controller class to listen for changes to the "selectionIndexes" property. When the selection is changed, I do this:
Code:
for (Bill *bill in bills.billsArray)
{
[bill setIsSelected:NO];
}
if ([[billsArrayController selectedObjects] count] != 0)
{
[[[billsArrayController selectedObjects] objectAtIndex:0] setIsSelected:YES];
}
}
Whilst typing this I thought of the idea of overriding the NSResponder becomeFirstResponder and resignFirstResponder methods in my view subclass to alter the view appearance to show selection; would this be a good way to do it?
As always, thanks in advance for any help .