Draw a custom NSTableRowView depending on whether the next row will be a group

I have a custom implementation of NSTableRowView to display my data cells. The table also contains group rows using a simple NSTextField .

In my view of a specific row, I need to slightly modify the drawing of the lower delimiter depending on whether the next line below is a data cell (i.e. my custom row) or group heading.

In the case of the group header, I do not need to draw a separator, otherwise I get a 2px separator, as shown in the screenshot.

Is there a way to get a link to the next (or previous) instance of NSTableRowView from [NSTableRowView drawBackgroundInRect:...] ?

separators

+4
source share
1 answer

I correct that the table view delegate implements -tableView:rowViewForRow: :?

If so, give the table delegate a view of help:

  • Add the drawsSeparator property to your own string class.
  • In the string class, check the value of this property in drawRect and adjust the drawing accordingly.
  • Set drawsSeparator in a row in rowViewForRow . You can call -tableView:isGroupRow: using row + 1 to determine if the next row is a group (after checking to make sure you are not on the last row).
+8
source

Source: https://habr.com/ru/post/1396984/


All Articles