The **Window** module provides basic capabilities for managing windows, including creating and destroying windows and setting serial port attributes.
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.
> **NOTE**<br/>
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.
> **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.
> 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.
| TYPE_INPUT_METHOD<sup>9+</sup> | 2 | Input method window. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_STATUS_BAR<sup>9+</sup> | 3 | Status bar.|
| TYPE_STATUS_BAR<sup>9+</sup> | 3 | Status bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_PANEL<sup>9+</sup> | 4 | Notification panel. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_KEYGUARD<sup>9+</sup> | 5 | Lock screen.|
| TYPE_KEYGUARD<sup>9+</sup> | 5 | Lock screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6 | Volume bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7 | Navigation bar. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_FLOAT<sup>9+</sup> | 8 | Floating window.|
| TYPE_FLOAT<sup>9+</sup> | 8 | Floating window. This type can be used only in the stage model.<br>**Required permissions**: ohos.permission.SYSTEM_FLOAT_WINDOW|
| TYPE_WALLPAPER<sup>9+</sup> | 9 | Wallpaper.|
| TYPE_WALLPAPER<sup>9+</sup> | 9 | Wallpaper. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_DESKTOP<sup>9+</sup> | 10 | Home screen.|
| TYPE_DESKTOP<sup>9+</sup> | 10 | Home screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11 | Recent tasks screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | Dock bar on the home screen.|
| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | Dock bar on the home screen. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13 | Voice assistant. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
| TYPE_POINTER<sup>9+</sup> | 14 | Mouse.|
| TYPE_POINTER<sup>9+</sup> | 14 | Mouse. This type can be used only in the stage model.<br>This is a system API and cannot be called by third-party applications.|
## AvoidAreaType<sup>7+</sup>
## AvoidAreaType<sup>7+</sup>
...
@@ -42,26 +47,41 @@ Enumerates the types of the area where the window cannot be displayed.
...
@@ -42,26 +47,41 @@ Enumerates the types of the area where the window cannot be displayed.
| statusBarColor | string | Yes | Yes | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
| statusBarColor | string | Yes | Yes | Background color of the status bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| isStatusBarLightIcon<sup>7+</sup> | boolean | No | Yes | Whether any icon on the status bar is highlighted. |
| isStatusBarLightIcon<sup>7+</sup> | boolean | No | Yes | Whether any icon on the status bar is highlighted. |
| statusBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the status bar. |
| statusBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the status bar. |
| navigationBarColor | string | Yes | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
| navigationBarColor | string | Yes | Yes | Background color of the navigation bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| isNavigationBarLightIcon<sup>7+</sup> | boolean | No | No | Whether any icon on the navigation bar is highlighted. |
| isNavigationBarLightIcon<sup>7+</sup> | boolean | No | No | Whether any icon on the navigation bar is highlighted. |
| navigationBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the navigation bar. |
| navigationBarContentColor<sup>8+</sup> | string | No | Yes | Color of the text on the navigation bar. |
| UNSPECIFIED | 0 | Unspecified. The orientation is determined by the system.|
| PORTRAIT | 1 | Portrait. |
| LANDSCAPE | 2 | Landscape. |
| PORTAIT_INVERTED | 3 | Reverse portrait. |
| LANDSCAPE_INVERTED | 4 | Reverse landscape.|
| AUTO_ROTATION | 5 | Auto rotation.|
| AUTO_ROTATION_PORTRAIT | 6 | Auto rotation in the vertical direction.|
| AUTO_ROTATION_LANDSCAPE | 7 | Auto rotation in the horizontal direction.|
| AUTO_ROTATION_RESTRICTED | 8 | Switched-determined auto rotation.|
| AUTO_ROTATION_PORTRAIT_RESTRICTED | 9 | Switched-determined auto rotation in the vertical direction.|
| AUTO_ROTATION_LANDSCAPE_RESTRICTED | 10 | Switched-determined auto rotation in the horizontal direction.|
| LOCKED | 11 | Locked.|
## SystemBarRegionTint<sup>8+</sup>
## SystemBarRegionTint<sup>8+</sup>
Describes the callback for a single system bar.
Describes the callback for a single system bar.
...
@@ -91,7 +132,7 @@ This is a system API and cannot be called by third-party applications.
...
@@ -91,7 +132,7 @@ This is a system API and cannot be called by third-party applications.
| type | [WindowType](#windowtype) | Yes | Yes | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
| type | [WindowType](#windowtype) | Yes | Yes | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.|
| isEnable | boolean | Yes | Yes | Whether the system bar is displayed. |
| isEnable | boolean | Yes | Yes | Whether the system bar is displayed. |
| region | [Rect](#rect) | Yes | Yes | Current position and size of the system bar. |
| region | [Rect](#rect) | Yes | Yes | Current position and size of the system bar. |
| backgroundColor | string | Yes | Yes | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, **\#00FF00** or **\#FF00FF00**.|
| backgroundColor | string | Yes | Yes | Background color of the system bar. The value is a hexadecimal RGB or aRGB color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| contentColor | string | Yes | Yes | Color of the text on the system bar. |
| contentColor | string | Yes | Yes | Color of the text on the system bar. |
## SystemBarTintState<sup>8+</sup>
## SystemBarTintState<sup>8+</sup>
...
@@ -102,10 +143,10 @@ This is a system API and cannot be called by third-party applications.
...
@@ -102,10 +143,10 @@ This is a system API and cannot be called by third-party applications.
| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. |
| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is `false`. |
| isLayoutFullScreen<sup>7+</sup> | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. |
| isLayoutFullScreen<sup>7+</sup> | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is `false`. |
| focusable<sup>7+</sup> | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. |
| 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**. |
| 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. |
| 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>(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>**NOTE**<br>This attribute is deprecated since API version 9.<br> |
| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**. |
| 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**. |
| 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**. |
| isRoundCorner<sup>7+</sup> | boolean | Yes | Yes | Whether the window has rounded corners. The default value is `false`. |
| isTransparent<sup>7+</sup> | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**. |
| isTransparent<sup>7+</sup> | boolean | Yes | Yes | Whether the window is transparent. The default value is `false`. |
| 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 | 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).|
| id | string | Yes | Window ID. |
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
| 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 window created. |
| 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 | 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).|
| id | string | Yes | Window ID. |
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
| type | [WindowType](#windowtype) | Yes | Window type. |
| 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).|
| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. |
| callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained. |
**Example**
**Example**
```js
```js
varwindowClass=null;
varwindowClass=null;
window.getTopWindow(this.context,(err,data)=>{
window.getTopWindow(this.context,(err,data)=>{
if(err.code){
if(err.code){
console.error('Failed to obtain the top window. Cause: '+JSON.stringify(err));
console.error('Failed to obtain the top window. Cause: '+JSON.stringify(err));
return;
return;
}
}
windowClass=data;
windowClass=data;
console.info('Succeeded in obtaining the top window. Data: '+JSON.stringify(data));
console.info('Succeeded in obtaining the top window. Data: '+JSON.stringify(data));
});
});
```
```
## window.getTopWindow<sup>8+</sup>
## window.getTopWindow<sup>8+</sup>
...
@@ -474,26 +514,215 @@ Obtains the top window of the current application. This API uses a promise to re
...
@@ -474,26 +514,215 @@ Obtains the top window of the current application. This API uses a promise to re
| 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).|
| 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 information. |
| callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the properties of the status bar and navigation bar. |
**Example**
**Example**
```js
```js
vartype='systemBarTintChange';
window.on('systemBarTintChange',(data)=>{
windowClass.on(type,(data)=>{
console.info('Succeeded in enabling the listener for systemBarTint changes. Data: '+JSON.stringify(data));
console.info('Succeeded in enabling the listener for systemBarTint changes. Data: '+JSON.stringify(data));
});
});
```
```
## off('systemBarTintChange')<sup>8+</sup>
## off('systemBarTintChange')<sup>8+</sup>
...
@@ -535,19 +763,20 @@ This is a system API and cannot be called by third-party applications.
...
@@ -535,19 +763,20 @@ 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)> | No | Callback used to return the information. |
| callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the properties of the status bar and navigation bar. |
**Example**
**Example**
```js
```js
vartype='systemBarTintChange';
window.off('systemBarTintChange');
windowClass.off(type);
```
```
## Window
## Window
In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a **Window** instance and then call a method in this instance.
Represents the current window instance, which is the basic unit managed by the window manager.
In the following API examples, you must use [getTopWindow()](#windowgettopwindow), [create()](#windowcreate7), or [find()](#windowfind7) to obtain a `Window` instance and then call a method in this instance.
### hide<sup>7+</sup>
### hide<sup>7+</sup>
...
@@ -563,19 +792,19 @@ This is a system API and cannot be called by third-party applications.
...
@@ -563,19 +792,19 @@ This is a system API and cannot be called by third-party applications.
Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses an asynchronous callback to return the result.
Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses an asynchronous callback to return the result.
...
@@ -952,27 +1181,27 @@ Obtains the area where this window cannot be displayed, for example, the system
...
@@ -952,27 +1181,27 @@ Obtains the area where this window cannot be displayed, for example, the system
| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area.|
| callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. |
| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
**Example**
**Example**
```js
```js
vartype=window.AvoidAreaType.TYPE_SYSTEM;
vartype=window.AvoidAreaType.TYPE_SYSTEM;
windowClass.getAvoidArea(type,(err,data)=>{
windowClass.getAvoidArea(type,(err,data)=>{
if(err.code){
if(err.code){
console.error('Failed to obtain the area. Cause:'+JSON.stringify(err));
console.error('Failed to obtain the area. Cause:'+JSON.stringify(err));
return;
return;
}
}
console.info('Succeeded in obtaining the area. Data:'+JSON.stringify(data));
console.info('Succeeded in obtaining the area. Data:'+JSON.stringify(data));
| type | [AvoidAreaType](#avoidareatype) | Yes | Type of the area. **TYPE_SYSTEM** indicates the default area of the system. **TYPE_CUTOUT** indicates the notch.|
| type | [AvoidAreaType](#avoidareatype7) | Yes | Type of the area. `TYPE_SYSTEM` indicates the default area of the system. `TYPE_CUTOUT` indicates the notch. **TYPE_SYSTEM_GESTURE** indicates the gesture area. **TYPE_KEYBOARD** indicates the soft keyboard area.|
| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
| isLayoutFullScreen | boolean | Yes | Whether to enable the full-screen mode for the window layout, in which the status bar and navigation bar are displayed.|
| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.|
| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.|
| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
| names | Array | Yes | Whether to display the status bar and navigation bar. For example, to display the status bar and navigation bar, set this parameter to **["status", "navigation"]**. By default, they are not displayed.|
| names | Array | Yes | Whether to display the status bar and navigation bar.<br>For example, to display the status bar and navigation bar, set this parameter to `["status", "navigation"]`. By default, they are not displayed.|
| path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
| path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.|
**Example**
**Example**
```js
```js
windowClass.isShowing((err,data)=>{
windowClass.isShowing((err,data)=>{
if(err.code){
if(err.code){
console.error('Failed to check whether the window is showing. Cause:'+JSON.stringify(err));
console.error('Failed to check whether the window is showing. Cause:'+JSON.stringify(err));
return;
return;
}
}
console.info('Succeeded in checking whether the window is showing. Data: '+JSON.stringify(data))
console.info('Succeeded in checking whether the window is showing. Data: '+JSON.stringify(data));
});
});
```
```
### isShowing<sup>7+</sup>
### isShowing<sup>7+</sup>
...
@@ -1353,20 +1722,20 @@ Checks whether this window is displayed. This API uses a promise to return the r
...
@@ -1353,20 +1722,20 @@ Checks whether this window is displayed. This API uses a promise to return the r
| 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 information. |
| callback | Callback<[AvoidArea](#avoidarea7)> | Yes | Callback used to return the area. |
**Example**
**Example**
```js
```js
vartype='systemAvoidAreaChange';
windowClass.on('systemAvoidAreaChange',(data)=>{
windowClass.on(type,(data)=>{
console.info('Succeeded in enabling the listener for system avoid area changes. Data: '+JSON.stringify(data));
console.info('Succeeded in enabling the listener for system avoid area changes. Data: '+JSON.stringify(data));
| 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 information. |
| callback | Callback<[AvoidArea](#avoidarea7)> | No | Callback used to return the area. |
| type | string | Yes | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | Yes | Callback used to return the area and area type.|
**Example**
```js
windowClass.on('avoidAreaChange',(type,data)=>{
console.info('Succeeded in enabling the listener for system avoid area changes. type:'+JSON.stringify(type)+'Data: '+JSON.stringify(data));
| type | string | Yes | Event type. The value is fixed at `avoidAreaChange`, indicating the event of changes to the area where the window cannot be displayed.|
| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | No | Callback used to return the area and area type.|
**Example**
```js
windowClass.off('avoidAreaChange');
```
### on('keyboardHeightChange')<sup>7+</sup>
### on('keyboardHeightChange')<sup>7+</sup>
...
@@ -1470,19 +1886,18 @@ Enables listening for keyboard height changes.
...
@@ -1470,19 +1886,18 @@ Enables listening for keyboard height changes.
| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
**Example**
**Example**
```js
```js
windowClass.isSupportWideGamut((err,data)=>{
windowClass.isSupportWideGamut((err,data)=>{
if(err.code){
if(err.code){
console.error('Failed to check whether the window support WideGamut. Cause:'+JSON.stringify(err));
console.error('Failed to check whether the window support WideGamut. Cause:'+JSON.stringify(err));
return;
return;
}
}
console.info('Succeeded in checking whether the window support WideGamut Data: '+JSON.stringify(data))
console.info('Succeeded in checking whether the window support WideGamut Data: '+JSON.stringify(data));
})
})
```
```
### isSupportWideGamut<sup>8+</sup>
### isSupportWideGamut<sup>8+</sup>
...
@@ -1544,18 +2004,18 @@ Checks whether this window supports the wide color gamut mode. This API uses a p
...
@@ -1544,18 +2004,18 @@ Checks whether this window supports the wide color gamut mode. This API uses a p
| Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.|
| Promise<boolean> | Promise used to return the result. The value `true` means that the wide color gamut mode is supported, and `false` means the opposite.|
**Example**
**Example**
```js
```js
letpromise=windowClass.isSupportWideGamut();
letpromise=windowClass.isSupportWideGamut();
promise.then((data)=>{
promise.then((data)=>{
console.info('Succeeded in checking whether the window support WideGamut. Data: '+JSON.stringify(data))
console.info('Succeeded in checking whether the window support WideGamut. Data: '+JSON.stringify(data));
}).catch((err)=>{
}).catch((err)=>{
console.error('Failed to check whether the window support WideGamut. Cause: '+JSON.stringify(err));
console.error('Failed to check whether the window support WideGamut. Cause: '+JSON.stringify(err));
});
});
```
```
### setColorSpace<sup>8+</sup>
### setColorSpace<sup>8+</sup>
...
@@ -1570,19 +2030,19 @@ Sets this window to the wide or default color gamut mode. This API uses an async
...
@@ -1570,19 +2030,19 @@ Sets this window to the wide or default color gamut mode. This API uses an async
| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.|
| callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the result. When the color gamut mode is obtained successfully, `err` is `undefined`, and `data` is the current color gamut mode.|
**Example**
**Example**
```js
```js
windowClass.getColorSpace((err,data)=>{
windowClass.getColorSpace((err,data)=>{
if(err.code){
if(err.code){
console.error('Failed to get window colorspace. Cause:'+JSON.stringify(err));
console.error('Failed to get window colorspace. Cause:'+JSON.stringify(err));
return;
return;
}
}
console.info('Succeeded in getting window colorspace. Cause:'+JSON.stringify(data))
console.info('Succeeded in getting window colorspace. Cause:'+JSON.stringify(data));
})
})
```
```
### getColorSpace<sup>8+</sup>
### getColorSpace<sup>8+</sup>
...
@@ -1651,26 +2111,26 @@ Obtains the color gamut mode of this window. This API uses a promise to return t
...
@@ -1651,26 +2111,26 @@ Obtains the color gamut mode of this window. This API uses a promise to return t
Sets the background color for this window. This API uses an asynchronous callback to return the result.
Sets the background color for this window. This API uses an asynchronous callback to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
Sets the background color for this window. This API uses a promise to return the result.
Sets the background color for this window. This API uses a promise to return the result. In the stage model, this API must be used after [loadContent](#loadcontent9).
| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, **#00FF00** or **#FF00FF00**.|
| color | string | Yes | Background color to set. The value is a hexadecimal color value and is case insensitive, for example, `#00FF00` or `#FF00FF00`.|
| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.|
| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
| callback | AsyncCallback<void> | Yes | Callback used to return the execution result. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
@@ -1987,56 +2479,24 @@ Sets whether the area outside the subwindow is touchable. This API uses a promis
...
@@ -1987,56 +2479,24 @@ Sets whether the area outside the subwindow is touchable. This API uses a promis
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory| Description |
| --------- | ------- | ---- | ---------------- |
| --------- | ------- | ---- | ---------------- |
| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value **true** means that such an area is touchable, and **false** means the opposite.|
| touchable | boolean | Yes | Whether the area outside the subwindow is touchable. The value `true` means that such an area is touchable, and `false` means the opposite.|
| FOREGROUND | 1 | The window stage is running in the foreground.|
| FOREGROUND | 1 | The window stage is running in the foreground.|
| ACTIVE | 2 | The window stage gains focus.|
| ACTIVE | 2 | The window stage gains focus.|
| INACTIVE | 3 | The window stage loses focus.|
| INACTIVE | 3 | The window stage loses focus.|
...
@@ -2175,79 +2702,124 @@ Describes the lifecycle of a window stage.
...
@@ -2175,79 +2702,124 @@ Describes the lifecycle of a window stage.
## WindowStage<sup>9+</sup>
## WindowStage<sup>9+</sup>
Before calling any of the following APIs, you must use `[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)` to create a **WindowStage** instance.
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.
Loads content from a page associated with a local storage to the main window in this window stage. This API uses an asynchronous callback to return the result.
Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<Array<[Window](#window)>> | Yes | Callback used to return all the subwindows.|
| path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
| path | string | Yes | Path of the page from which the content will be loaded. |
| storage | LocalStorage | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.|