Search code examples
cocoainterface-buildernstableviewnstextfield

How to make NSTextField only editable if exactly one item is selected in NSTableView?


In a master-detail application, my master table view allows multiple selections. I use NSArrayController to populate the table view.

I want the text fields in the detail view only be editable, when exactly one item in the master table view is selected.

Disabling "Allows Editing Multiple Values Selection" in the text field's binding is not enough, because it only disables editing, when the multiple selected items have different values. I want editing disabled always, as soon as more than one item is selected.

Is this achievable from within interface builder?


Solution

  • I found that a combination of

    1. Selecting "Always Use Multi Value Marker" on the NSArrayController and

    enter image description here

    1. Deselecting "Allows Editing Multiple Value Selection" on the NSTextField's value binding

    enter image description here

    results in the behaviour I was looking for.