Cocoa : Multiline NSTextFieldCell in a NSOutlineView
-
16-10-2019 - |
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 ;)
Solution
- Configure your table column's dataCell to wrap instead of scroll with -[NSCell setWraps:]
- Implement -[NSObject outlineView: heightOfRowByItem:] in your outline view delegate.
- 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