Ad

Dialog: Confirmation When Dismissed

- 1 answer

Topic: I want to be able to cancel a dismiss call on a dialog.

I am entering information thorugh a dialog. When data inside the dialog has changed and the user dismisses the dialog without saving (by pressing back or clicking outside of the dialog), I want to be able to prevent that dismis by showing a confirmation dialog, that asks the user if he really wants do dismiss the dialog. An analagy for what I am looking for is in VBA, where the cancel-variable of a beforeSave-listener can be set to "true", so that the file is not saved, even though save is pressed.

I could not find a solution that I can place inside the dismissListener of the dialog.

Thanks a lot in advance and best regards!

Ad

Answer

You can maintain the state of dialog open/ close in a boolean and handle it. When you open the dialog you make it true and when user clicks back or outside the dialog check that boolean and show the alert pop-up and when dialog closes (dismisses) make boolean to false.

Ad
source: stackoverflow.com
Ad