Search code examples
objective-ccocoansoutlineview

How do I select all selected checkboxes in the NSOutlineView


I have NSOutlineView with checkboxes:

enter image description here

When I select multiple rows they become blue, however if I check any checkbox, I only select the related item (and its children).

enter image description here

Instead, I would like to check all selected items in the table.

Thanks


Solution

  • Here's a solution:

    1. Create an action in your view controller to handle the new behavior.
    2. Connect your NSButtonCell's action selector to this action.
    3. In the new action, you need to propagate the cell's value to the rest of the selected rows. Call -numberOfSelectedRows on your outline view to find out if there are any more rows you need to act on, and -selectedRowIndexes to get access to the row indexes.
    4. After you make the changes to the fields in the model, depending on how your outline view gets its data, you may need to call -reloadData to update the display of the other rows.