Interface Question


I’m working on a new interface for a project where I need the user to select one or more items from a list of 20 tactical executions.

I suppose I could do five rows of four items with check boxes and then return an array of any that have their box state checked, but that looks a bit clunky. I was thinking of using a radio button matrix but I’m not sure how to collect multiple-checked items from a matrix.

Is there anything else in the cocoa arsenal that I’m missing that might be a more elegant solution?



You can make a matrix contain checkboxes rather than radio buttons. You will need to change the mode from radio to (probably) list. But IMO the disadvantage of matrixes is that you can’t have empty slots – if suddenly you need to go from 20 to 21, things can get messy.

I’d go with the separate checkboxes. Give each a unique tag, and have them all trigger the same action. The action would then add or remove them from a property containing either a mutable array or mutable set.

Something like this:

-- initialize your property somewhere
 set my buttonList to current application's NSMutableArray's array()
    on clickedOn_(sender)
        set theTag to sender's tag()
        set theState to sender's state() as boolean
        if theState then
            my buttonList's addObject_(theTag)
            my buttonList's removeObject_(theTag)
        end if
    end clickedOn_