Redwood
Redwood

Reputation: 69322

How do I bind the enabled binding of a button to whether or not an NSArrayController has a selection?

I want to bind the enabled state of an NSButton to whether or not an NSArrayController has any selected items.

How do I do this?

Upvotes: 13

Views: 3831

Answers (3)

CheshireKat
CheshireKat

Reputation: 461

This is the answer for IB:

enter image description here

If you need to setup the OR relationship with other NSArrayController (or other value), there is the section Enabled 2 , and so on. So, in my case, i have:

enter image description here

Upvotes: 3

sbooth
sbooth

Reputation: 16976

Another option is to bind to selectedObjects.@count

Upvotes: 22

Alex
Alex

Reputation: 26859

Generally speaking, binding the enabled binding to the canRemove property of the array controller should give you what you want. After all, you can only remove an object if there's one selected.

Upvotes: 18

Related Questions