mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-05 10:13:00 +02:00
docs(api): add example for tauri://close-requested event usage
This commit is contained in:
@@ -247,8 +247,8 @@ async function ask(
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { confirm } from '@tauri-apps/api/dialog';
|
||||
* const confirm = await confirm('Are you sure?', 'Tauri');
|
||||
* const confirm2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
|
||||
* const confirmed = await confirm('Are you sure?', 'Tauri');
|
||||
* const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
|
||||
* ```
|
||||
*
|
||||
* @param {string} message The message to show.
|
||||
|
||||
@@ -53,10 +53,10 @@
|
||||
*
|
||||
* Events can be listened using `appWindow.listen`:
|
||||
* ```typescript
|
||||
* import { appWindow } from '@tauri-apps/api/window'
|
||||
* appWindow.listen('tauri://move', ({ event, payload }) => {
|
||||
* const { x, y } = payload // payload here is a `PhysicalPosition`
|
||||
* })
|
||||
* import { appWindow } from "@tauri-apps/api/window"
|
||||
* appWindow.listen("tauri://move", ({ event, payload }) => {
|
||||
* const { x, y } = payload; // payload here is a `PhysicalPosition`
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Window-specific events emitted by the backend:
|
||||
@@ -78,6 +78,16 @@
|
||||
* #### 'tauri://close-requested'
|
||||
* Emitted when the user requests the window to be closed.
|
||||
* If a listener is registered for this event, Tauri won't close the window so you must call `appWindow.close()` manually.
|
||||
* ```typescript
|
||||
* import { appWindow } from "@tauri-apps/api/window";
|
||||
* import { confirm } from '@tauri-apps/api/dialog';
|
||||
* appWindow.listen("tauri://close-requested", async ({ event, payload }) => {
|
||||
* const confirmed = await confirm('Are you sure?');
|
||||
* if (confirmed) {
|
||||
* await appWindow.close();
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* #### 'tauri://focus'
|
||||
* Emitted when the window gains focus.
|
||||
|
||||
Reference in New Issue
Block a user