current-popup returns the current popup pane or
nil if there is none. A current popup exists in the scope of callbacks which are done while a dialog is displayed on the screen in the current process.
If the dialog was raised by an explicit call to display-dialog or popup-confirmer, current-popup returns the first argument of display-dialog or popup-confirmer. For other functions that raise a dialog (such as the prompt-for-file, prompt-for-confirmation and so on), the result is CAPI pane created by the system.
CAPI User Guide and Reference Manual (Macintosh version) - 25 Feb 2015