@bosco Thank you for your suggestion. Interesting results.
I had placed 2 print statements around the code - one after the main function call return,
selection = get_selection(sel,value)
select = custom.MyListDialog(title=title,items=selection)
print('After dialog call - Select',select)
and the other where the custom code is defined - after the view.wait_modal() statement.
c = _MyListDialogController(title, items, frame, multiple, done_button_title=done_button_title)
c.view.present('sheet')
c.view.wait_modal()
print('MyListDialog', c.selected_item)
return c.selected_item
Without ui.in_background, both print statements returned None.
With ui.in_background ( around the definition ), the print statement following the wait_modal showed the correct result. However the order of print statements was incorrect ie the result printed before the definition if that makes sense.
… results …
After dialog call - Select None
MyListDialog {'title': 'BUSINESS', 'accessory_type': 'none'}
Apologies for the long reply.