Detecting When SelectFromList is Closed

Hi all,

I’m currently using forms.SelectFromList.show( … ) to prompt the user for input. The problem is this: if I select an item, and then decide to close the tool instead of continuing with the operation, the program continues with the selected item as if I had pressed the “continue” button rather than the “close” buton. Is there any way to differentiate if the user has closed the dialog with the x, or if they’ve pressed the button at the bottom?

Thanks in advance!

I use forms.alert() and sys.exit() whenever I use SelectFromList to get a notification indicating the action was intentionally cancelled and didn’t just fail to execute properly.

    res = forms.SelectFromList.show(
        {'Approved': approved_items, 'Unapproved': unapproved_items},
        title='Upper Attachment List',
        group_selector_title='Select approved/unapproved:',
        multiselect=False
    )

    if res is None:
        forms.alert('Upper Attachment selection cancelled.', exitscript=True)
        sys.exit()
3 Likes

Thanks! This is exactly the desired behavior.