How to deselect all rows of a table in NSOutlineView when clicking into empty view space?

For example, when I click on the red dot below:

before

I want the following selection to occur:

enter image description here

I customized the view-based NSOutlineView using bindings for both the data source and the selection indices. So far I have been trying to override the TableCellView getFirstResponder as well as override the NSOutlineView startFirstResponder, but does NSOutlineView seem to never give up the status of the first responder?

Some tips would be much appreciated!

+2
source share
2 answers

. NSOutlineView mouseDown:, , . , . deselectAll: NSOutlineView.

, , .

+3

setAction: NSOutlineView.

[mOutlineView setAction:@selector(doClick:)];
[mOutlineView setTarget:self];

-(IBAction) doClick:(id)sender;
{
    if ([mOutlineView clickedRow] == -1) {
        [mOutlineView deselectAll:nil];
    }
}
+1

Source: https://habr.com/ru/post/1715419/


All Articles