I have a strange situation that I would like to get some help with. I have written a script with a class that contains a set of widgets that are common to several views so I want the common widgets to appear in the same place in any of the views. For the example code below, I have just one widget, a textview. When I type into the textview, I want a tableview dropdown to appear with a selection from a list that matches the text in the textview. When I select a row from the textview, I want the tableview delegate action to populate the textview with the selected row from the tableview and then have the tableview be hidden. The code below almost does this. With line 7 (#main.author_result.text = self.items[row]) commented out, once the row is selected from the tableview the tableview is hidden but the textview isn't populated with the tableview row. If I uncomment line 7, when I select a row from the tableview, the textview is populated properly but the tableview isn't hidden. This seems like very strange behavior. Can someone advise me how to correct the code to work as described above? Thanks.
```
import ui
class MyTableViewDelegate(object):
def init(self,items):
self.items = items
def tableview_did_select(self, tableview, section, row):
#main.author_result.text = self.items[row]
tableview.hidden = True
pass
class MyAuthorDelegate (object):
def textview_did_change_selection(self, textview):
author_unique = ['Aaaa', 'Aabb', 'Bbbb', 'Bccc']
length = len(textview.text)
options = []
for author in author_unique:
if author[:length] == textview.text:
options.append(author)
datasource = ui.ListDataSource(options)
dropDown = ui.TableView()
dropDown.data_source = datasource
dropDown.delegate = MyTableViewDelegate(options)
dropDown.x = 100
dropDown.y = 55
dropDown.width = 250
dropDown.row_height = 25
view.add_subview(dropDown)
pass
class Common_View (object):
def init(self,args,*kwargs): #
pass
self.author_result = ui.TextView(name='author',frame=(100,5,250,40), border_color='black', border_width=3, text=
'', font=('Arial Rounded MT Bold',20))
w, h = ui.get_screen_size()
view = ui.View(name='Test', bg_color='lightblue', frame=(0, 0, w, h))
main = Common_View()
view.add_subview(main.author_result)
main.author_result.delegate = MyAuthorDelegate()
nav_view = ui.NavigationView(view)
nav_view.present('sheet')```