View Full Version : How to change the highlight color of a row in a tableview

Mar 12, 2009, 12:04 PM
I need to be able to modify the behavior of my tableview. When I click on a row, i would like it to be selected but show now signs of being selected. I may in the future want to just draw a frame around the selected row - but for now I would just like it to do nothing. In other words I want to disable the blue highliting when a cell is clicked. The row does need to be selectable however because the cells are editable and one of the columns consists of NSPopUpButtonCells.

I have subclassed NSTableView and NSTableColumn.

Help with this would make my week! Thanks in advance.

Mar 12, 2009, 09:02 PM
See http://www.cocoadev.com/index.pl?AlternatingRowColors

Mar 13, 2009, 01:13 PM
Thanks for the link. It did provide a lot of insight into the whole issue. And I imagine that somewhere in there are critical pieces of the puzzle. I still can't control the highlighting on the non-text cells. For my simple test I just have one column of text and one column whose cells are NSPopUpButtonCells. I have subclassed NSTableColumn to deal with the popups and all that works great except for this highlighting issue.

I would love to get my head around the whole cycle that occurs from the time i click on a row until the time I release the mouse and observe the selected and highlighted row. ie seems like the mousedown event would kick things off. From there I am sure a whole chain of messages are sent from object to object in a very specific order. If I could find out exactly what is going on and in what order, I could probably track down exactly what method is doing the actual drawing of the highlight color. From there I assume I could code my way out of this situation.

I am all ears. Any help at all would help me cope. thanks

Mar 13, 2009, 02:00 PM
Oops sorry I mixed up highlighting and alternating color :o

I believe you can override highlightSelectionInClipRect and draw what you want there to replace the color.