0

How do I use a copy of the same NSTableCellView in multiple columns in Interface Builder? In my table, there is only one cell identifier, which is a member of an NSTableCellView subclass, that is used throughout the entire table. Is this possible?

EDIT 1: This is my current project. The userInput NSTextField is wired up as an IBOutlet in the TextInputTableCellView class. My problem is that, when I try to add a TextInputTableCellView to the KeyColumn, I don't know where to begin.

Xcode Interface Builder

Brandon Bradley
  • 3,160
  • 4
  • 22
  • 39
  • What did you try? – Willeke Mar 22 '17 at 15:37
  • I have attempted to just use Command + C (however that didn't work.) My primary problem is that there is a text field in the table cell view, which the subclass of NSTableCellView of which my cell is an instance, references as an IBOutlet. The problem is that, when I create the cell in the other column, I don't know what to do with the textField. – Brandon Bradley Mar 23 '17 at 03:05
  • Why do you want to use one `NSTableCellView` in all columns? – Willeke Mar 23 '17 at 10:01
  • I want to be able to have the same view / behavior in the cells of all columns. My thought was that the way to do this, was by using the same NSTableCellView. Is that not the correct way? – Brandon Bradley Mar 23 '17 at 11:36
  • It depends on the behaviour and the number of columns. – Willeke Mar 23 '17 at 15:13
  • @Willeke The behavior is defined in the TextInputTableCellView subclass, and there are two columns. – Brandon Bradley Mar 23 '17 at 23:43
  • Can't you use the default table view and change the class of the table cell view in both columns? `NSTableCellView` already has a `textField` outlet. – Willeke Mar 24 '17 at 02:05
  • The TextInputTableCellView supports text entry through an NSTextField, which NSTableCellView doesn't have. I just need to ensure that the Cell that uses the TextInputTableCellView has an NSTextField within it. – Brandon Bradley Mar 24 '17 at 08:05
  • You're describing the default behaviour. – Willeke Mar 24 '17 at 11:23
  • @Willeke There is no mechanism to enter text in the NSTableCellView class. How are you suggesting input is received in the default implementation? – Brandon Bradley Mar 24 '17 at 21:49
  • How do you create the tableview? The template in IB contains `NSTextField`s. – Willeke Mar 25 '17 at 11:39
  • @Willeke It contains one in the image because I added it manually. I am trying to figure out how to have a class that has the NSTextField in it automatically. – Brandon Bradley Mar 26 '17 at 02:42
  • Why don't you want to use the IB template? – Willeke Mar 26 '17 at 11:17
  • @Willeke Because I don't know how to do so without creating a new class for that cell (because the TextInputCellView subclass has an @IBOutlet). – Brandon Bradley Mar 26 '17 at 13:24
  • The default `NSTableCellView` class has a `textField` outlet which is connected to the `NSTextField` in the template. – Willeke Mar 26 '17 at 21:55
  • @Willeke From Apple's Documentation: https://developer.apple.com/reference/appkit/nstablecellview the textField property is only for displaying text. The textField property of a default NSTableCellView does not provide a way for the user to edit the stringValue property. – Brandon Bradley Mar 27 '17 at 01:45
  • 1
    Switch "Behavior" to "Editable" in IB or set `isEditable` in code. More info: [View based NSTableView editing](http://stackoverflow.com/questions/28281045/view-based-nstableview-editing) – Willeke Mar 27 '17 at 09:31
  • @Willeke Wow. I can't believe I didn't catch that. In any case, thanks for all of your help. – Brandon Bradley Mar 27 '17 at 12:05

0 Answers0