New method for detecting cancel button in dialogs