I have a Matrix of radio buttons with mode set to Highlight so user can select more than one button. I have a bound property to the matrix named selectedValues under Selected Values of the App Delegate. When I run this I can select multiple values and it will return a list of the selected values but the problem is if I deselect a value it still will list that value until I select something else. I have validate immediately checked in the bindings. What can I do to get the property updated if something is deselected?
Using X-Code 4.6 on 10.8.2
property selectedValues : missing value --Bound to Selected Values of App Delegate.
on getAllSelectedMatrix_(sender) -- Action handler to get selected values.
log selectedValues
end getAllSelectedMatrix_
I am not sure how you are getting the selected values, but I am assuming you are referring to the selected cells.
If so , have a look at NSMatrix’s selectedCells . It should return an array of currently selected cells/buttons.
I’m getting the values with bindings. it returns an array of selected cells but like I said, clicking a cell back to the off state it still returns the cell name.
There is no binding for selected cell. I’m using selected values.
The problem seems to be that nothing gets notified if a radio button is clicked to off state then you try to get the selected values. It still thinks it is in the on state. If however you click one off and click another to on everything is updated.
This is not the expected behavior. Maybe you should use a matrix of checkboxes instead.
Couldn’t you bind an action from your matrix to your appDelegate? So, when you click in a radio button, your “on clickedMatrix” handler will be called, then you can get your matrix’s selected row and use it as an index to update your array?
If you want to get the state of every button of your matrix at each click, then you parse the matrix’s cells integer value (as cells are buttons, they have a value of 0 or 1) into your “on clickedMatrix” handler.
Changing the matrix to check boxes gave me the result I was looking for.
This is a large project so I’m trying to use bindings only as much as possible to keep things simple.