0

So I had a view based TableView with 3 text columns. TableView is editable and I can tab across columns to edit. I then decided I needed a "type" for each column which could let user select a fixed set of types.

I deleted the NSTextField and replaced it with NSComboBox. I made sure it was Behavior="Editable" in IB and I gave it 3 static values in IB as well. Can't get it to work.

First, nothing shows up in the column. I cannot select it. When I hit <tab> key while editing it just skips over that column to the next column. It's like TableView does not know it's there.

I must be missing something very fundamental. Appreciate any pointers.

Rakesh
  • 3,370
  • 2
  • 23
  • 41
griftopia
  • 135
  • 1
  • 3
  • 10
  • Is the combo box inside the table cell view? – Willeke Jan 23 '18 at 15:04
  • If you don't specify the selected value the combo box is supposed not to show a default value. Try this: In the model declare `@objc dynamic var types = ["alpha", "beta", "gamma"]` and `@objc dynamic var selectedType : String { return types[0] }`. In Interface Builder bind the `Content` of the combo box to `Table Cell View` > `objectValue.types` and `Value` to `Table Cell View` > `objectValue.selectedValue`. Does it show `alpha` in all rows. Basically it should work to edit the combo box if editing is enabled. Is `editable` of the column enabled, too (Table Column > ⌥⌘4)? – vadian Jan 23 '18 at 20:01
  • "I must be missing something very fundamental." You are. You are not showing a single line of code. – El Tomato Jan 23 '18 at 22:54
  • I'm using IB to set the possible values on NSComboBoxCell. My problem was a lack of understanding on how control behaves. I thought since NSComboBox extends NSTextField, and I also want to allow value to be "edited" by typing, I should create and return NSTextField. I now am returning NSComboBox and it works. – griftopia Jan 24 '18 at 13:47

0 Answers0