2009 04 15Debugging with Activity Monitor
To draw a custom header in a table view, derive from NSTableHeaderCell
and write your drawing code in highlight:withFrame:inView:
. This works fine until you disable column selection : highlight:withFrame:inView:
is never called, although the header cell obviously looks highlighted. To understand why, we can use … Activity Monitor ! As strange as it sounds, double click your process listing to get a sample button. Instead of launching Shark and getting a trace from everything, we can sample for one moment while clicking around to highlight those table header cells. Behold :
// Column selection enabled 1 -[NSTableHeaderView drawRect:] 1 -[NSTableHeaderView _drawColumnHeaderWithIndexes:] 1 -[NSTableHeaderView _drawHeaderOfColumn:] 1 -[NSTableHeaderCell highlight:withFrame:inView:] 1 -[NSTableHeaderCell _drawThemeContents:highlighted:inView:] 1 -[NSTableHeaderCell drawInteriorWithFrame:inView:] // Column selection disabled 3 -[NSTableHeaderView drawRect:] 3 -[NSTableHeaderView _drawColumnHeaderWithIndexes:] 3 -[NSTableHeaderView _drawHeaderOfColumn:] 3 -[NSTableHeaderView _drawHeaderCell:withFrame:withStateFromColumn:] 3 -[NSTableHeaderCell drawWithFrame:inView:] 3 -[NSTableHeaderCell _drawThemeContents:highlighted:inView:] 3 -[NSTableHeaderCell _drawBezelWithFrame:highlighted:inView:]
Et voilà ! When column selection is disabled, highlight:withFrame:inView:
is never called. _drawBezelWithFrame:highlighted:inView:
is called instead. Hey, there's even some code using that very method ! Using it to draw the highlighted cell does work.