Question

This is a question about best practices for UI behavior with the NSTableView.

I have an NSTableView whose contents are refreshed occasionally. The user has the ability to select none, one, or many rows in the table. When the data is refreshed, some rows can be removed or reordered. The default behavior of NSTableView seems to be to keep the same row indexes selected, no matter how the data is reordered (I understand the behavior, since how would the NSTableView know where the rows moved to?)

I could change this behavior to modify the selection after reloading the data so that the user's original selections stay selected, even if they have moved around. This would change the row indexes that are selected, so it might also be jarring to the user.

Does Apple have anything to say about this situation or is there a standard behavior?

Was it helpful?

Solution

I couldn't find anything in the HIG, but the NSArrayController documentation and the "Cocoa Bindings Programming Topics" document, in the section "Preserves Selection" section, indicates that the default behavior is to preserve the selection when the contents change.

See also the documentation for setPreservesSelection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top