1
votes

BACKGROUND:

I have a tableview with a list of names. When you click on a name in the list, it displays additional detail information in another section of the window. Everything is connected and is working correctly.

However...

I would like to use Type Select with this table and have run into the following snag:

When I start typing a name (while the table is selected) it correctly highlights the appropriate name in the table BUT the detailed information to the right of the table does not change.

I know the reason is the code for changing the detail information is in an IBAction method which is only called when you click to select a name in the list, and uses the [sender clickedRow] call to get the index of the selected name.

I also suspect that I need to use the [tableView selectedRow] (since it is being selected, but you are not clicking on it) but I am not quite certain where or how to perform this check.

I'm also thinking that since "type select" isn't sending an action message, I won't be able to use [sender selectedRow] but rather will use [tableView selectedRow]...

QUESTION:

How can I tell when the selected row in a tableview has changed via type select?

Thanks!

1

1 Answers

0
votes

Implement the tableViewSelectionDidChange: delegate method in your controller, and ensure that your controller is the NSTableView's delegate.

You could update your view with something like:

- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
    [relatedView updateInformationFromRow:[[aNotification object] selectedRow]];
}

From the documentation:

tableViewSelectionDidChange: Informs the delegate that the table view’s selection has changed.

Within that, you would update your related view. You could use the aNotification's object, which will be a NSTableViewSelectionDidChangeNotification, again from the documentation, is:

Posted after an NSTableView object's selection changes. The notification object is the table view whose selection changed. This notification does not contain a userInfo dictionary.