CloseWatcher Class
Listens to the close requests of the user (https://html.spec.whatwg.org/multipage/interaction.html#the-closewatcher-interface), e.g. the Escape key: a custom component (a picker, a sidebar) closes itself in the close event, as the dialogs and the popovers do with their own close watchers. A close request closes the close watchers of the most recent group of the window: the close watchers created without user activation are grouped with the previous one, so that a page cannot trap the close requests of the user.
public sealed class CloseWatcher : EventTarget- Inheritance
EventTargetCloseWatcher
Constructors
| Name | Description |
|---|---|
| CloseWatcher(CloseWatcherOptions?) | Creates a close watcher of the window of the current global object (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher). |
| CloseWatcher(Window, CloseWatcherOptions?) | Creates a close watcher of a window (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher). |
CloseWatcher overloads
CloseWatcher(CloseWatcherOptions?)
CloseWatcher.csCreates a close watcher of the window of the current global object (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher).
public CloseWatcher(CloseWatcherOptions? options = null)Parameters
optionsCloseWatcherOptions?- The options, or null.
Exceptions
DomException- There is no current window, or its document is not fully active (
InvalidStateError).
See also
CloseWatcher(Window, CloseWatcherOptions?)
CloseWatcher.csCreates a close watcher of a window (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher).
public CloseWatcher(Window window, CloseWatcherOptions? options = null)Parameters
windowWindow- The window whose close requests are watched.
optionsCloseWatcherOptions?- The options, or null.
Exceptions
DomException- The document of the window is not fully active (
InvalidStateError).
Properties
| Name | Description |
|---|---|
| OnCancel | Gets or sets the event handler of the cancel event. |
| OnClose | Gets or sets the event handler of the close event. |
OnCancel
CloseWatcher.csGets or sets the event handler of the cancel event.
OnClose
CloseWatcher.csGets or sets the event handler of the close event.
Methods
| Name | Description |
|---|---|
| Close() | Closes the watcher: fires close, without cancel, and destroys it (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-close). |
| Destroy() | Destroys the watcher: it no longer receives the close requests and fires no event (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-destroy). |
| RequestClose() | Acts as if the user sent a close request to this close watcher: fires cancel (it can always be canceled), then closes the watcher (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-requestclose). |
Close()
CloseWatcher.csCloses the watcher: fires close, without cancel, and destroys it (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-close).
public void Close()Destroy()
CloseWatcher.csDestroys the watcher: it no longer receives the close requests and fires no event (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-destroy).
public void Destroy()RequestClose()
CloseWatcher.csActs as if the user sent a close request to this close watcher: fires cancel (it can always be canceled), then closes the watcher (https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher-requestclose).
public void RequestClose()