Reputation: 2288
For example when I click on the red dot below:
I want the following deselection to occur:
I set up the view-based NSOutlineView using bindings for both the data source and the selection indexes. So far i've tried to override the TableCellView becomeFirstResponder and also override NSOutlineView's becomeFirstResponder however it seems NSOutlineView never actually gives up first responder status?
Some advice would be very much appreciated!
Upvotes: 3
Views: 2013
Reputation: 145
Swift 5. in NSOutlineViewDelegate
func outlineViewSelectionDidChange(_ notification: Notification) {
//1
guard let outlineView = notification.object as? NSOutlineView else {
return
}
outlineView.deselectAll(nil)
}
Upvotes: 0
Reputation: 22930
Use setAction:
method of NSOutlineView
.
[mOutlineView setAction:@selector(doClick:)];
[mOutlineView setTarget:self];
-(IBAction) doClick:(id)sender;
{
if ([mOutlineView clickedRow] == -1) {
[mOutlineView deselectAll:nil];
}
}
Upvotes: 1
Reputation: 4797
I found this post on the topic. The solution appears to be in creating a subclass of NSOutlineView
and overriding mouseDown:
so that you can determine whether the click was on a row or not. When the click is on a row you just dispatch to super. If it's not you send deselectAll:
to your NSOutlineView
.
I haven't tried it myself but there are various posts around which come up with comparable code.
Upvotes: 4