Extension for NSTableView based on view

I have a view-based NSTableView for which some cells have enough content that is not suitable. I would like the cell to expand automatically when the user hovers over the cell.

When looking for this, this seems to be the default behavior for a cell-based NSTableView. There are even methods like shouldShowCellExpansionForTableColumn, which, according to the document, are intended only for table views based on cells. Elsewhere in the document, is it implied that this extension behavior is even the default for default table table views?

- (BOOL)tableView:(NSTableView *)tableView shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row 

I get the impression that I'm missing something obvious.

Goal:

  • To be able to place several rows of NSTextField objects in a cell based on the view (more than there is speed for processing).
  • If the content is full, put a visual indicator in the cell
  • When the user hovers over a tooltip in a cell, expand the view to show all the content
+4
source share
2 answers

You seem to be on the right track, as this should work for cell-based NSTableViews. You need to put tableView: shouldShowCellExpansionForTableColumn: row: in the tableView delegate. You can answer YES for the column of interest.

With a table based on the view where you use NSTextFields, these scroll, crop or wrap, but there is no expand on hover option. You can set the tooltip text to be the same as the content, which can be a smart solution.

0
source

Have you tried changing the height of the row ( tableView:heightOfRow: caused by a mouse action? You may need to reload the table view.

0
source

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


All Articles