Getting Matrix Values

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_

Hi there

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.

Regards

P

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.

I have never used binding in that manner, I will definitely check it out.

One other option to check on the bindings tab in Xcode “Continuously Update Value”
If you figure it out, let us know your findings.

Good luck

P

Remember when you have bound variables you should be using the keyword “MY” before the variable/property so that KVO works on it.

on getAllSelectedMatrix_(sender) – Action handler to get selected values.
log my selectedValues
end getAllSelectedMatrix_

If I’m not mistaking you only need to use “MY” when setting values. Adding “MY” to this code didn’t change the output.

on getAllSelectedMatrix_(sender)
  log my selectedValues    
end getAllSelectedMatrix_

–3 radio buttons clicked on then one turned off it still returns all three.

2013-04-08 15:26:50.712 Matrix Selection[3158:303] (
Front,
Reverse,
“X-Side”
)

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.

Hello,

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.

Regards,

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.

Thanks for the responses!