Search code examples
objective-ccocoansoutlineview

How to disable expanding all subtree of element in NSOutlineView?


As you know, if you option-click expanding triangle of element in NSOutlineView, it expands all subtree of this element. But, if this subtree contains too many elements (filesystem tree for example) effect of this action can be tragic for your application. The question is, how to disable this option-click feature?


Solution

  • Solved by adding this method to outline view delegate.

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item
    {
        return ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) == 0;
    }