Question

I am developing a Cocoa application.

I have a NSOutlineView displaying custom cells ( cells inherits from NSTextFieldCell). The problem I am facing to is that the cell text is only displayed on one line... how can I have a multiline textField ???

Thanks for reading ;)

Was it helpful?

Solution

  1. Configure your table column's dataCell to wrap instead of scroll with -[NSCell setWraps:]
  2. Implement -[NSObject outlineView: heightOfRowByItem:] in your outline view delegate.
  3. Use -[NSCell cellSizeForBounds:] to find the height of the cell for a specific width. For cellSizeForBounds:, you can pass a really tall rectangle that's the width of your column, and it will return a smaller rectangle that is the right height for the text to fit in that width.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top