Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
IGGrid - Change Selection Color Based On Row
posted

I am trying to have the selection color, based on row, be different.  Defining a color in the selection theme will change all of my rows when selected to the same color.  I would like my rows to be a different color based on row. Specifically, I am trying to make it look like the rows are not being selected at all.  Because I am using the data source helper, and alternating colors(white & blue), the only alternative I have found to make the rows still selectable, and not appear as though they are changing colors, is to use the willDisplayCell method which I have displayed below:

-(void)gridView:(IGGridView*)gridView willDisplayCell:(IGGridViewCell*)cell forPath:(IGCellPath*)path{

    //overwrite selected color, makes row colors not change when selected

    NSColor *cellColor= cell.backgroundColor        

    cell.selectedColor = cellColor;

}

However, if my rows exceed beyond the views scrollview, and I scroll down, the cells IGCellPath will be reset to the new viewable cell, which causes my selected colors to be skewed. IE. if my fifth row is not viewable, but then I scroll to have it be the first row from the top of my gridView, it's new rowPath is now 1, instead of 5. I will then notice that if I select a white row, it will sometimes be blue, and vice versa.  I assume this caused by dequeResuableCell, which is a function I will still need to implement.  

I am not sure if I have missed alternative methods/properties, or could implement willDisplayCell in a better fashion. Is there any other way to have my rows with alternating colors still be selectable, but retain the current background color for each row?