Question

I have a TextView and any text entered into the TextView can be saved to a TableView (or should I say NSMutableArray!). I have this working without issues. The problem I am now having is because a lot of text could be typed into the TextView, not all the text is visible within the TableView Cell. I don't want to make the TableView Cells larger and would like to keep them at their current size.

Ultimately I want to be able to click on a TableView Cell and it would show all the text to the user to be able to read and edit if required and then be saved back to the original TableCell with the updated details.

I can't figure out a way of doing this and would appreciate any help on this....thanks.

Was it helpful?

Solution

You could implement this in two different ways, depending on the requirements of your design:

  • In-table editing: the user clicks the cell and the text becomes editable. You should be able to get this working by implementing a view based table view. Just add an NSTextView to your view and set setHidden:YES. When the user clicks the cell, you show the NSTextView. Once done editing (by clicking a button or by clicking another cell???), you can update your model and hide the NSTextView again. For this to work, you would need a view based NSTableView.

  • Out-of-table editing by using an NSPopover. When the user clicks the cell, you show a separate NSView with all your editing controls in it, wrapped in an NSPopover. By passing the bounds of the cell to the popover, you can "attach" the popover to the specific cell you are editing. Once editing is done you update your model and dismiss the popover.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top