# PopupEvent

This event class is fired when a popup is about to be displayed, or when a popup is closed.

This event has two subtypes:

- popupopen: Fires when a new popup is about to be displayed. This is fired before the popup is shown (and before any side effects of showing it occur, such as removing a menu or a prior popup that was already showing). If you cancel it by calling preventDefault(), the popup isn't displayed, and any side effects are skipped.
- popupclose: Fires after a popup has been closed. This is fired after the fact, so the event can't be canceled.

The event target for this event type is the mainWindow object.

When a new popup replaces an old popup, the "open" event for the new popup will occur before the "close" event for the old popup. The events occur in this order (which might seem a little surprising) because the proximate cause of the old popup closing is the opening of the new popup, and it's not a foregone conclusion that the new popup will open at all until the "open" event returns without canceling the new popup.

## Properties

This event type has all of the standard event properties and methods (see the Event class). In addition, it has the following:

- id: A string with the ID of the popup. See Popups for a list of the system popup IDs. For a user-defined popup, this is the ID string you specify in the popup descriptor passed to mainWindow.showPopup() when creating the popup.