The `Window` module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows.
The `Window` module provides basic window management capabilities, such as creating and destroying the current window and setting properties for the current window.
This module provides the following common window-related functions:
-[Window](#window): the current window instance, which is the basic unit managed by the window manager.
-[WindowStage](#windowstage9): window manager that manages windows.
[Window](#window): the current window instance, which is the basic unit managed by the window manager.
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> API version 9 is a canary version for trial use. The APIs of this version may be unstable.
## Modules to Import
...
...
@@ -46,7 +44,7 @@ Enumerates the types of the area where the window cannot be displayed.
Enumerates the window modes.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API and cannot be called by third-party applications.
@@ -154,7 +152,7 @@ Describes the window properties.
| focusable<sup>7+</sup> | boolean | Yes | No | Whether the window can gain focus. The default value is `true`. |
| touchable<sup>7+</sup> | boolean | Yes | No | Whether the window is touchable. The default value is `true`. |
| brightness | number | Yes | Yes | Screen brightness. The value ranges from 0 to 1. The value `1` indicates the maximum brightness. |
| dimBehindValue<sup>(deprecated)</sup> | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.<br>This attribute is supported since API version 7 and deprecated since API version 9.<br>|
| dimBehindValue<sup>7+</sup> | number | Yes | Yes | Dimness of the window that is not on top. The value ranges from 0 to 1. The value `1` indicates the maximum dimness.|
| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is `false`. |
| isPrivacyMode<sup>7+</sup> | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is `false`. |
| isRoundCorner<sup>7+</sup> | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`. |
...
...
@@ -191,13 +189,14 @@ Creates a subwindow. This API uses an asynchronous callback to return the result
| ctx | Context | Yes | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
| ctx | [Context](js-apis-Context.md) | Yes | Current application context.|
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window created. |
| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created. |
**Example**
...
...
@@ -257,11 +256,11 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| ctx | Context | Yes | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md).|
| ctx | [Context](js-apis-Context.md) | Yes | Current application context.|
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
...
...
@@ -286,7 +286,7 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| ctx | Context | Yes | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
| ctx | Context | Yes | Current application context.<br>For the definition of `Context` of API version 8, see [Context](js-apis-Context.md).<br>For the definition of `Context` of API version 9, see [AbilityContext](js-apis-ability-context.md).|
| ctx | [Context](js-apis-Context.md) | Yes | Current application context.|
**Return value**
...
...
@@ -486,7 +486,7 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v
Enables listening for properties changes of the status bar and navigation bar.
This is a system API and cannot be called by third-party applications.
**System API**: This is a system API and cannot be called by third-party applications.
| type | string | Yes | Type of event to listen for. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the properties of the status bar and navigation bar. |
| type | string | Yes | Type of event to listen for. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| type | string | Yes | Event type. The value is fixed at `systemBarTintChange`, indicating the property change event of the status bar and navigation bar.|
| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the properties of the status bar and navigation bar. |
| type | string | Yes | Type of event to listen for. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. |
**Example**
...
...
@@ -1431,7 +1433,7 @@ Disables listening for changes to the area where the window cannot be displayed.
| type | string | Yes | Type of event to listen for. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| type | string | Yes | Event type. The value is fixed at `systemAvoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the area. |
**Example**
...
...
@@ -1452,7 +1454,7 @@ Enables listening for keyboard height changes.
Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result.
Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. When in privacy mode, the window content cannot be captured or recorded.
Sets whether this window is in privacy mode. This API uses a promise to return the result.
Sets whether this window is in privacy mode. This API uses a promise to return the result. When in privacy mode, the window content cannot be captured or recorded.
| FOREGROUND | 1 | The window stage is running in the foreground.|
| ACTIVE | 2 | The window stage gains focus.|
| INACTIVE | 3 | The window stage loses focus.|
| BACKGROUND | 4 | The window stage is running in the background.|
## WindowStage<sup>9+</sup>
Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.
Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a `WindowStage` instance.