Hmm. That is good information, but I’m not sure if that was the issue. I tried implementing your fix like this:
def regain_focus(self):
ctypes.windll.user32.ShowWindow(self, 4)
ctypes.windll.user32.SetForegroundWindow(self.as_foreground_window)
def listbox_entire_model_got_focus(self):
button_name = 'listbox_entire_model_got_focus'
selected_index = self.listbox_entire_model.SelectedIndex
if selected_index > -1:
self.current_tag = self.display.model[selected_index].elem
if len(self.display.model) > 0:
show_element(self.current_tag)
self.regain_focus()
self.refresh_listboxes_and_quantities()
self.current_tag_index = selected_index
p('{} succeeded'.format(button_name))
else: p('selected_index not > -1. Likely no list items in listbox.')
Is that what you were suggesting?
When the ListBox gets focus, the element is shown, the modeless dialog and Revit both become unresponsive (except weirdly, you can still zoom in and out of the revit view), then self.regain_focus should re-focus the modeless dialog…
Still, the UI does not regain responsiveness. I think the modeless window does successfully get set to foreground, but I guess this doesn’t fix anything.
Either way, I worked around the issue by not triggering the pop-up dialog to begin with, and I’m pretty happy with that solution.