omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    listdatasource
    2
    3
    2947
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cook
      cook last edited by

      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)

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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 yourself

        tv.selected_row=(0,row)
        tv.tableview_did_select(tv,0,row)
        
        1 Reply Last reply Reply Quote 1
        • cook
          cook last edited by

          @jonb many thanks, that got it!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors