I have 2 identical matrices of checkboxes. Each matrix has 18 checkboxes. The titles for each checkbox is different within the matrix but the same as the other matrix. In other words, I created the first matrix of 18 checkboxes and then duplicated it. Clear as mud?
These matrices are going to be used to choose what data is displayed within 2 different text boxes. What I’d like to have happen is if a checkbox in Matrix A is selected (i.e., it’s state is ON) then I’d like the corresponding checkbox in Matrix B is be disabled. Likewise if a checkbox in Matrix B is selected (i.e., it’s state is ON) then I’d like the corresponding checkbox in Matrix A to be disabled. If neither corresponding checkboxes is selected (i.e., the state for both is OFF) then I’d like them both to be enabled. Clear as mud on a bright sunny day?
This sounds like a job for bindings. Unfortunately bindings and my brain don’t seem to play nicely together. Bindings hurt my brain! :lol: Can somebody help bindings learn to play nicely with my brain? (or visa versa)
Are multiple selections allowed in each matrix? Also, what is the starting state, all off? Off the top of my head, this doesn’t seem like it would work with bindings, at least not bindings alone. It would be easy enough to use bindings to have one matrix’s check boxes to be the opposite of the others, but if some of the corresponding boxes are the same (i.e. both off) that would require some more logic, I think.
Yes, multiple selections are allowed for both matrices and the initial state will be all checkboxes set to the OFF state. I will save the states via User Defaults so that they won’t need to be reselected each time the application is ran.
I don’t know about doing it with bindings, but I think this action method connected to both matrixes should do what you want:
property parent : class "NSObject"
property mat1:missing value -- IBOutlet for first matrix
property mat2:missing value -- IBOutlet for second matrix
on changeState_(sender) -- IBAction connected to both matrixes
if sender is mat1 then
mat2's cellAtRow_column_(sender's selectedRow(),0)'s setEnabled_(1 - sender's selectedCell()'s |state|())
else
mat1's cellAtRow_column_(sender's selectedRow(),0)'s setEnabled_(1 - sender's selectedCell()'s |state|())
end
end