Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Resetting ListDataSource selection
-
Does anyone know how to reset the ListDataSource selection?
By default it is
-1
... no selection.When we do an action, you can get the row number. Example:
ListDataSource.action = dostuff def dostuff(sender): sender.selected_row
But if I just do
ListDataSource.selected_row = -1
it does nothing.I can do a
ListDataSource.reload()
but that's not ideal because it could take precious processing power to reload my list. (for now this is what I've done) -
The tableview selected_row controls the displayed selected row.
When the user taps, the tv calls tableview_did_select on the delegate, which is where it sets the ListDataSource selected row so the action can see it.So... if you just want to set the selected row, do it on the tableview.
If you want the action called, you need to call the delegate yourselftv.selected_row=(0,row) tv.tableview_did_select(tv,0,row)
-
@jonb many thanks, that got it!