Search code examples
cocoanstableviewmultipleselection

Deselection of a row taking time in NSTableView


I have faced the issue in my application in which I show a NSTableView. This table view shows list of rows with NSButtonCell as DataCell for the entire NSTableColumn. After trying a lot of ways to find the root cause for the delay, I gave up and created a bare minimal project just having a NSTableView showing a list of rows containing "Hi" text. I am surprised to see that the delay exists in this application as well.

Use case tried: I selected 4 of the rows using Cmd and mouse click. Then I selected only one row from the list of previously selected rows with out using Command. The later action took 2-4 seconds to reflect. 4sec in 10.8.5 OSX and 2sec in 10.11.6 OSX

Copying the the code here for your reference -

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    [self.tableView setDelegate:self];
    [self.tableView setDataSource:self];    
    [self.tableView setAllowsMultipleSelection:YES];
    [self.tableView setAllowsEmptySelection:YES];
}

#pragma mark - Table View -

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    return @"Hi";
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
    return 10;
}

@end

Please help me to fix this lag or suggest with an alternative way to make this action immediate.


Solution

  • Time taken for Deselection of a row equals to the double click speed configured in our system preferences.

    I have filed an apple bug and got to know this. In my system the double click interval is set to long time, so the deselection in table view also taking considerable amount of time.

    Many thanks apple and also want to share this as you wouldn't waste time debugging it.