Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 801
Lawrence Johnston Avatar asked Jun 04 '09 18:06

Lawrence Johnston


3 Answers

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.

like image 85
Alex Avatar answered Nov 20 '22 03:11

Alex


Another option is to bind to selectedObjects.@count

like image 22
sbooth Avatar answered Nov 20 '22 04:11

sbooth


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

like image 3
CheshireKat Avatar answered Nov 20 '22 03:11

CheshireKat