TableView Selected Row
I have a ListDataSource as the data_source and delegate for a TableView.
What is the relationship between the TableView.selected_row and the TableView.data_source. selected_row? They don’t appear to talk to each other. You can set one without affecting the other, and vice versa. Is that by design, or am I missing something?
ListDataSource is a simple pure-python table data source and delegate object, and while the selected_row attribute is writable (it probably should be a read-only property), it does nothing if set manually. It will contain the correct selected row index as long as you don't manually fiddle with it. It is really only provided as a convenience because the data source action() callback will receive the ListDataSource as its argument when a selection is made, so you can look at the selected_row to see which row was selected.
TableView.selected_row is the property to use if you want to modify the current selected row in code. Since TableViews actually support a more sophisticated sections-and-rows way of displaying data, the selected_row is a tuple of (section, row), but section should always be 0 for tables using the ListDataSource as their data source delegate.
So: read from LastDataSource.selected_row to see what row index is selected in action() callbacks, but use TableView.selected_row = (0, row) to set the actual selected row directly.
Thanks for the explanation. I have been using the tuple as you indicated because I do manually fiddle with it at times, which is how I noticed the disconnect. It's now more of a curiosity.