提交 d3e2b2c6 编写于 作者: W wusongqing

update docs against 5395+5527+5521+5689+5922+5911+6081+5989

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 c91df51a
# Window # Window
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.
## Modules to Import ## Modules to Import
...@@ -18,23 +23,23 @@ Enumerates the window types. ...@@ -18,23 +23,23 @@ Enumerates the window types.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Value| Description |
| ----------------- | ------ | ------------------ | | ----------------- | ------ | ------------------ |
| TYPE_APP | 0 | Application subwindow. | | TYPE_APP | 0 | Application subwindow. This type can be used only in the FA model.|
| TYPE_SYSTEM_ALERT | 1 | System alert window.| | TYPE_SYSTEM_ALERT | 1 | System alert window.|
| TYPE_INPUT_METHOD<sup>9+</sup> | 2 | Input method window.| | 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.| | 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.| | 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.| | 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.| | 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.| | 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.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Value | Description |
| ----------- | ------ | ------------------ | |----------------------------------|-----| ----------------- |
| TYPE_SYSTEM | 0 | Default area of the system.| | TYPE_SYSTEM | 0 | Default area of the system.|
| TYPE_CUTOUT | 1 | Notch. | | TYPE_CUTOUT | 1 | Notch. |
| TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2 | Gesture area. |
| TYPE_KEYBOARD<sup>9+</sup> | 3 | Soft keyboard area. |
## WindowMode<sup>7+</sup> ## WindowMode<sup>7+</sup>
Enumerates the window modes of an application. Enumerates the window modes.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
| ---------- | ---- | ----------------------------- |
| UNDEFINED | 1 | The window mode is not defined by the application. |
| FULLSCREEN | 2 | The application is displayed in full screen. |
| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. |
| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. |
| FLOATING | 5 | The application is displayed in a floating window.|
## WindowLayoutMode<sup>9+</sup>
Enumerates the window layout modes.
This is a system API and cannot be called by third-party applications. This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Value | Description |
| ---------- | ------ | ----------------------------- | | ---------- | ---- | ----------------------------- |
| UNDEFINED | 1 | The window mode is not defined by the application. | | WINDOW_LAYOUT_MODE_CASCADE | 0 | Cascade mode. |
| FULLSCREEN | 2 | The application is displayed in full screen. | | WINDOW_LAYOUT_MODE_TILE | 1 | Tile mode. |
| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. |
| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. |
| FLOATING | 5 | The application is displayed in a floating window.|
## SystemBarProperties ## SystemBarProperties
...@@ -71,13 +91,34 @@ Describes the properties of the status bar and navigation bar. ...@@ -71,13 +91,34 @@ Describes the properties of the status bar and navigation bar.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
| 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. |
## Orientation<sup>9+</sup>
Enumerates the window orientations.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
| ------------------------------------- | ---- | ----------------------------- |
| 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.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ---------- | --------------------------------------------------- | ---- | ---- | -------------------------- | | ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
| displayId | number | Yes | No | ID of the current physical screen. | | displayId | number | Yes | No | ID of the current physical screen. |
| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | Yes | All system bar information changed.| | regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | Yes | All system bar information that has been changed.|
## Rect<sup>7+</sup> ## Rect<sup>7+</sup>
...@@ -128,6 +169,7 @@ Describes the area where the window cannot be displayed. ...@@ -128,6 +169,7 @@ Describes the area where the window cannot be displayed.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ---------- | ------------- | ---- | ---- | ------------------ | | ---------- | ------------- | ---- | ---- | ------------------ |
| visible<sup>9+</sup> | boolean | Yes | Yes | Whether the area is visible.|
| leftRect | [Rect](#rect) | Yes | Yes | Rectangle on the left of the screen.| | leftRect | [Rect](#rect) | Yes | Yes | Rectangle on the left of the screen.|
| topRect | [Rect](#rect) | Yes | Yes | Rectangle at the top of the screen.| | topRect | [Rect](#rect) | Yes | Yes | Rectangle at the top of the screen.|
| rightRect | [Rect](#rect) | Yes | Yes | Rectangle on the right of the screen.| | rightRect | [Rect](#rect) | Yes | Yes | Rectangle on the right of the screen.|
...@@ -154,16 +196,16 @@ Describes the window properties. ...@@ -154,16 +196,16 @@ Describes the window properties.
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- | | ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
| windowRect<sup>7+</sup> | [Rect](#rect) | Yes | Yes | Window size. | | windowRect<sup>7+</sup> | [Rect](#rect) | Yes | Yes | Window size. |
| type<sup>7+</sup> | [WindowType](#windowtype) | Yes | Yes | Window type. | | type<sup>7+</sup> | [WindowType](#windowtype) | Yes | Yes | Window type. |
| 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`. |
## ColorSpace<sup>8+</sup> ## ColorSpace<sup>8+</sup>
...@@ -182,32 +224,30 @@ create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): voi ...@@ -182,32 +224,30 @@ create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): voi
Creates a subwindow. This API uses an asynchronous callback to return the result. Creates a subwindow. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead. This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------- | | -------- | -------------------------------------- | ---- | ------------------------------------ |
| id | string | Yes | Window ID. | | id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. | | type | [WindowType](#windowtype) | Yes | Window type. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created.| | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
window.create("first", window.WindowType.TYPE_APP, (err, data) => { let promise = window.create("first", window.WindowType.TYPE_APP);
if (err.code) { promise.then((data)=> {
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); windowClass = data;
return; console.info('SubWindow created. Data: ' + JSON.stringify(data));
} }).catch((err)=>{
windowClass = data; console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
console.info('SubWindow created. Data: ' + JSON.stringify(data)) });
windowClass.resetSize(500, 1000); ```
});
```
## window.create<sup>7+</sup> ## window.create<sup>7+</sup>
...@@ -215,7 +255,7 @@ create(id: string, type: WindowType): Promise&lt;Window&gt; ...@@ -215,7 +255,7 @@ create(id: string, type: WindowType): Promise&lt;Window&gt;
Creates a subwindow. This API uses a promise to return the result. Creates a subwindow. This API uses a promise to return the result.
This API is deprecated since API version 8. You are advised to use [window.create<sup>8+</sup>](#windowcreate8) instead. This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -228,22 +268,22 @@ This API is deprecated since API version 8. You are advised to use [window.creat ...@@ -228,22 +268,22 @@ This API is deprecated since API version 8. You are advised to use [window.creat
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------------- | | -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.| | Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP); let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('SubWindow created. Data: ' + JSON.stringify(data)) console.info('SubWindow created. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
}); });
``` ```
## window.create<sup>8+</sup> ## window.create<sup>8+</sup>
...@@ -257,25 +297,25 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). ...@@ -257,25 +297,25 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;[Window](#window)&gt; | Yes | Callback used to return the window created. | | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the window created. |
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to create the Window. Cause: ' + JSON.stringify(err));
return; return;
} }
windowClass = data; windowClass = data;
console.info('Window created. Data: ' + JSON.stringify(data)) console.info('Window created. Data: ' + JSON.stringify(data));
windowClass.resetSize(500, 1000); windowClass.resetSize(500, 1000);
}); });
``` ```
## window.create<sup>8+</sup> ## window.create<sup>8+</sup>
...@@ -289,28 +329,28 @@ Creates a subwindow (in API version 8) or a system window (from API version 9). ...@@ -289,28 +329,28 @@ Creates a subwindow (in API version 8) or a system window (from API version 9).
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ | | ------ | ------------------------- | ---- | ------------------------------------------------------------ |
| 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. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ----------------------------------------------- | | -------------------------------- | --------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window created.| | Promise&lt;[Window](#window)&gt; | Promise used to return the window created. |
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('Window created. Data: ' + JSON.stringify(data)) console.info('Window created. Data:' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
}); });
``` ```
## window.find<sup>7+</sup> ## window.find<sup>7+</sup>
...@@ -322,24 +362,24 @@ Finds a window based on the ID. This API uses an asynchronous callback to return ...@@ -322,24 +362,24 @@ Finds a window based on the ID. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ---------------------------- | | -------- | -------------------------------------- | ---- | ------------------------------------ |
| id | string | Yes | Window ID. | | id | string | Yes | Window ID. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the window found.| | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the window found.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
window.find("alertWindow", (err, data) => { window.find("alertWindow", (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
return; return;
} }
windowClass = data; windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data)) console.info('window found. Data: ' + JSON.stringify(data));
}); });
``` ```
## window.find<sup>7+</sup> ## window.find<sup>7+</sup>
...@@ -357,22 +397,22 @@ Finds a window based on the ID. This API uses a promise to return the result. ...@@ -357,22 +397,22 @@ Finds a window based on the ID. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ----------------------------------------------- | | -------------------------------- | ------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the window found.| | Promise&lt;[Window](#window)&gt; | Promise used to return the window found.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.find("alertWindow"); let promise = window.find("alertWindow");
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data)) console.info('window found. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
}); });
``` ```
## window.getTopWindow ## window.getTopWindow
...@@ -380,29 +420,29 @@ getTopWindow(callback: AsyncCallback&lt;Window&gt;): void ...@@ -380,29 +420,29 @@ getTopWindow(callback: AsyncCallback&lt;Window&gt;): void
Obtains the top window of the current application. This API uses an asynchronous callback to return the result. Obtains the top window of the current application. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead. This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------- | | -------- | -------------------------------------- | ---- | -------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained.| | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
window.getTopWindow((err, data) => { window.getTopWindow((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 ## window.getTopWindow
...@@ -410,28 +450,28 @@ getTopWindow(): Promise&lt;Window&gt; ...@@ -410,28 +450,28 @@ getTopWindow(): Promise&lt;Window&gt;
Obtains the top window of the current application. This API uses a promise to return the result. Obtains the top window of the current application. This API uses a promise to return the result.
This API is deprecated since API version 8. You are advised to use [window.getTopWindow<sup>8+</sup>](#windowgettopwindow8) instead. This API can be used only in the FA model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | --------------------------------------------------------- | | -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.| | Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.getTopWindow(); let promise = window.getTopWindow();
promise.then((data)=> { promise.then((data)=> {
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));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) })
``` ```
## window.getTopWindow<sup>8+</sup> ## window.getTopWindow<sup>8+</sup>
...@@ -445,22 +485,22 @@ Obtains the top window of the current application. This API uses an asynchronous ...@@ -445,22 +485,22 @@ Obtains the top window of the current application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained. | | callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the top window obtained. |
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = 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
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| 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).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | --------------------------------------------------------- | | -------------------------------- | ----------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.| | Promise&lt;[Window](#window)&gt; | Promise used to return the top window obtained.|
**Example** **Example**
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.getTopWindow(this.context); let promise = window.getTopWindow(this.context);
promise.then((data)=> { promise.then((data)=> {
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));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
}) })
``` ```
## window.minimizeAll<sup>9+</sup>
minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
Minimizes all windows on a display. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| id | number | Yes | ID of the [display](js-apis-display.md#display). |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
import display from '@ohos.display'
import window from '@ohos.window'
var displayClass = null;
display.getDefaultDisplay((err, data) => {
if(err.code) {
return;
}
displayClass = data;
window.minimizeAll(displayClass.id, (err, data) => {
if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in minimizing all windows.');
});
});
```
## window.minimizeAll<sup>9+</sup>
minimizeAll(id: number): Promise&lt;void&gt;
Minimizes all windows on a display. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| id | number | Yes | ID of the [display](js-apis-display.md#display).|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
import display from '@ohos.display'
import window from '@ohos.window'
var displayClass = null;
display.getDefaultDisplay((err, data) => {
if(err.code) {
return;
}
displayClass = data;
let promise = window.minimizeAll(displayClass.id);
promise.then((data)=> {
console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
})
});
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void
Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
window.toggleShownStateForAllAppWindows((err, data) => {
if (err.code) {
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in toggling shown state for all app windows.');
})
```
## window.toggleShownStateForAllAppWindows<sup>9+</sup>
toggleShownStateForAllAppWindows(): Promise&lt;void&gt;
Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let promise = window.toggleShownStateForAllAppWindows();
promise.then((data)=> {
console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
})
```
## window.setWindowLayoutMode<sup>9+</sup>
setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;): void
Sets the window layout mode. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => {
console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
});
```
## window.setWindowLayoutMode<sup>9+</sup>
setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
Sets the window layout mode. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
promise.then((data)=> {
console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
})
```
## on('systemBarTintChange')<sup>8+</sup> ## on('systemBarTintChange')<sup>8+</sup>
...@@ -509,17 +738,16 @@ This is a system API and cannot be called by third-party applications. ...@@ -509,17 +738,16 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes | Callback used to return the information. | | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | Yes | Callback used to return the properties of the status bar and navigation bar. |
**Example** **Example**
```js ```js
var type = '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.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;[SystemBarTintState](#systembartintstate)&gt; | No | Callback used to return the information. | | callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | No | Callback used to return the properties of the status bar and navigation bar. |
**Example** **Example**
```js ```js
var type = '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.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
windowClass.hide((err, data) => { windowClass.hide((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('window hidden. data: ' + JSON.stringify(data)) console.info('window hidden. data: ' + JSON.stringify(data));
}) })
``` ```
### hide<sup>7+</sup> ### hide<sup>7+</sup>
...@@ -589,20 +818,20 @@ This is a system API and cannot be called by third-party applications. ...@@ -589,20 +818,20 @@ This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.hide(); let promise = windowClass.hide();
promise.then((data)=> { promise.then((data)=> {
console.info('window hidden. Data: ' + JSON.stringify(data)) console.info('window hidden. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
}) })
``` ```
### show<sup>7+</sup> ### show<sup>7+</sup>
...@@ -616,19 +845,19 @@ Shows this window. This API uses an asynchronous callback to return the result. ...@@ -616,19 +845,19 @@ Shows this window. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
windowClass.show((err, data) => { windowClass.show((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}) })
``` ```
### show<sup>7+</sup> ### show<sup>7+</sup>
...@@ -640,20 +869,20 @@ Shows this window. This API uses a promise to return the result. ...@@ -640,20 +869,20 @@ Shows this window. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.show(); let promise = windowClass.show();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
}) })
``` ```
### destroy<sup>7+</sup> ### destroy<sup>7+</sup>
...@@ -667,19 +896,19 @@ Destroys this window. This API uses an asynchronous callback to return the resul ...@@ -667,19 +896,19 @@ Destroys this window. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
windowClass.destroy((err, data) => { windowClass.destroy((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}) })
``` ```
### destroy<sup>7+</sup> ### destroy<sup>7+</sup>
...@@ -691,20 +920,20 @@ Destroys this window. This API uses a promise to return the result. ...@@ -691,20 +920,20 @@ Destroys this window. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.destroy(); let promise = windowClass.destroy();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) })
``` ```
### moveTo<sup>7+</sup> ### moveTo<sup>7+</sup>
...@@ -720,20 +949,20 @@ Moves this window. This API uses an asynchronous callback to return the result. ...@@ -720,20 +949,20 @@ Moves this window. This API uses an asynchronous callback to return the result.
| -------- | ------------------------- | ---- | ------------------------------------------------- | | -------- | ------------------------- | ---- | ------------------------------------------------- |
| x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.| | x | number | Yes | Distance that the window moves along the x-axis, in px. A positive value indicates that the window moves to the right.|
| y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.| | y | number | Yes | Distance that the window moves along the y-axis, in px. A positive value indicates that the window moves downwards.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.moveTo(300, 300, (err, data)=>{ windowClass.moveTo(300, 300, (err, data)=>{
if (err.code) { if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Window moved. Data: ' + JSON.stringify(data)) console.info('Window moved. Data: ' + JSON.stringify(data));
}); });
``` ```
### moveTo<sup>7+</sup> ### moveTo<sup>7+</sup>
...@@ -752,20 +981,20 @@ Moves this window. This API uses a promise to return the result. ...@@ -752,20 +981,20 @@ Moves this window. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.moveTo(300, 300); let promise = windowClass.moveTo(300, 300);
promise.then((data)=> { promise.then((data)=> {
console.info('Window moved. Data: ' + JSON.stringify(data)) console.info('Window moved. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
}) })
``` ```
### resetSize<sup>7+</sup> ### resetSize<sup>7+</sup>
...@@ -781,19 +1010,19 @@ Changes the size of this window. This API uses an asynchronous callback to retur ...@@ -781,19 +1010,19 @@ Changes the size of this window. This API uses an asynchronous callback to retur
| -------- | ------------------------- | ---- | -------------------------- | | -------- | ------------------------- | ---- | -------------------------- |
| width | number | Yes | New width of the window, in px.| | width | number | Yes | New width of the window, in px.|
| height | number | Yes | New height of the window, in px.| | height | number | Yes | New height of the window, in px.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.resetSize(500, 1000, (err, data) => { windowClass.resetSize(500, 1000, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Window size changed. Data: ' + JSON.stringify(data)) console.info('Window size changed. Data: ' + JSON.stringify(data));
}); });
``` ```
### resetSize<sup>7+</sup> ### resetSize<sup>7+</sup>
...@@ -812,20 +1041,20 @@ Changes the size of this window. This API uses a promise to return the result. ...@@ -812,20 +1041,20 @@ Changes the size of this window. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.resetSize(500, 1000); let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> { promise.then((data)=> {
console.info('Window size changed. Data: ' + JSON.stringify(data)) console.info('Window size changed. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setWindowType<sup>7+</sup> ### setWindowType<sup>7+</sup>
...@@ -842,20 +1071,20 @@ This is a system API and cannot be called by third-party applications. ...@@ -842,20 +1071,20 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| type | [WindowType](#windowtype) | Yes | Window type.| | type | [WindowType](#windowtype) | Yes | Window type.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var type = window.TYPE_APP; var type = window.WindowType.TYPE_APP;
windowClass.setWindowType(type, (err, data) => { windowClass.setWindowType(type, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
}); });
``` ```
### setWindowType<sup>7+</sup> ### setWindowType<sup>7+</sup>
...@@ -875,21 +1104,21 @@ This is a system API and cannot be called by third-party applications. ...@@ -875,21 +1104,21 @@ This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var type = window.TYPE_APP; var type = window.WindowType.TYPE_APP;
let promise = windowClass.setWindowType(type); let promise = windowClass.setWindowType(type);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
}); });
``` ```
### getProperties ### getProperties
...@@ -901,21 +1130,21 @@ Obtains the properties of this window. This API uses an asynchronous callback to ...@@ -901,21 +1130,21 @@ Obtains the properties of this window. This API uses an asynchronous callback to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | ------------------ | | -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes | Callback used to return the window properties.| | callback | AsyncCallback&lt;[WindowProperties](#windowproperties)&gt; | Yes | Callback used to return the window properties.|
**Example** **Example**
```js ```js
windowClass.getProperties((err, data) => { windowClass.getProperties((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
}); });
``` ```
### getProperties ### getProperties
...@@ -927,24 +1156,24 @@ Obtains the properties of this window. This API uses a promise to return the res ...@@ -927,24 +1156,24 @@ Obtains the properties of this window. This API uses a promise to return the res
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------------------- | ------------------------------------- | | ---------------------------------------------------- | ------------------------------- |
| Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.| | Promise&lt;[WindowProperties](#windowproperties)&gt; | Promise used to return the window properties.|
**Example** **Example**
```js ```js
let promise = windowClass.getProperties(); let promise = windowClass.getProperties();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)) console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err));
}); });
``` ```
### getAvoidArea<sup>7+</sup> ### getAvoidArea<sup>7+</sup>
getAvoidArea(type: AvoidAreaType, callback: AsyncCallback&lt;AvoidArea&gt;): void getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
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
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ |
| 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&lt;[AvoidArea](#avoidarea)&gt; | Yes | Callback used to return the area. | | callback | AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. |
**Example** **Example**
```js ```js
var type = window.AvoidAreaType.TYPE_SYSTEM; var type = 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));
}); });
``` ```
### getAvoidArea<sup>7+</sup> ### getAvoidArea<sup>7+</sup>
getAvoidArea(type: AvoidAreaType): Promise&lt;AvoidArea&gt; getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses a promise to return the result. Obtains the area where this window cannot be displayed, for example, the system bar area and notch. This API uses a promise to return the result.
...@@ -980,26 +1209,26 @@ Obtains the area where this window cannot be displayed, for example, the system ...@@ -980,26 +1209,26 @@ Obtains the area where this window cannot be displayed, for example, the system
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | ------------------------------------------------------------ | | ------ |----------------------------------| ---- | ------------------------------------------------------------ |
| 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.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------------- | --------------------------------------------- | |-----------------------------------------| ----------------------------------- |
| Promise&lt;[AvoidArea](#avoidarea)&gt; | Promise used to return the area.| | Promise&lt;[AvoidArea](#avoidarea7)&gt; | Promise used to return the area.|
**Example** **Example**
```js ```js
let promise = windowClass.getAvoidArea(); let promise = windowClass.getAvoidArea();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)) console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); console.error('Failed to obtain the area. Cause:' + JSON.stringify(err));
}); });
``` ```
### setFullScreen ### setFullScreen
...@@ -1014,20 +1243,20 @@ Sets whether to enable the full-screen mode for this window. This API uses an as ...@@ -1014,20 +1243,20 @@ Sets whether to enable the full-screen mode for this window. This API uses an as
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------------- | ---- | ---------------------------------------------- | | ------------ | ------------------------- | ---- | ---------------------------------------------- |
| isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var isFullScreen = true; var isFullScreen = true;
windowClass.setFullScreen(isFullScreen, (err, data) => { windowClass.setFullScreen(isFullScreen, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
}); });
``` ```
### setFullScreen ### setFullScreen
...@@ -1045,21 +1274,21 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro ...@@ -1045,21 +1274,21 @@ Sets whether to enable the full-screen mode for this window. This API uses a pro
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isFullScreen = true; var isFullScreen = true;
let promise = windowClass.setFullScreen(isFullScreen); let promise = windowClass.setFullScreen(isFullScreen);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setLayoutFullScreen<sup>7+</sup> ### setLayoutFullScreen<sup>7+</sup>
...@@ -1074,20 +1303,20 @@ Sets whether to enable the full-screen mode for the window layout. This API uses ...@@ -1074,20 +1303,20 @@ Sets whether to enable the full-screen mode for the window layout. This API uses
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var isLayoutFullScreen= true; var isLayoutFullScreen= true;
windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
}); });
``` ```
### setLayoutFullScreen<sup>7+</sup> ### setLayoutFullScreen<sup>7+</sup>
...@@ -1105,21 +1334,21 @@ Sets whether to enable the full-screen mode for the window layout. This API uses ...@@ -1105,21 +1334,21 @@ Sets whether to enable the full-screen mode for the window layout. This API uses
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isLayoutFullScreen = true; var isLayoutFullScreen = true;
let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
}); });
``` ```
### setSystemBarEnable<sup>7+</sup> ### setSystemBarEnable<sup>7+</sup>
...@@ -1133,21 +1362,21 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -1133,21 +1362,21 @@ Sets whether to display the status bar and navigation bar in this window. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var names = ["status", "navigation"]; var names = ["status", "navigation"];
windowClass.setSystemBarEnable(names, (err, data) => { windowClass.setSystemBarEnable(names, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
}); });
``` ```
### setSystemBarEnable<sup>7+</sup> ### setSystemBarEnable<sup>7+</sup>
...@@ -1161,25 +1390,25 @@ Sets whether to display the status bar and navigation bar in this window. This A ...@@ -1161,25 +1390,25 @@ Sets whether to display the status bar and navigation bar in this window. This A
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----- | ---- | ------------------------------------------------------------ | | ------ | ----- | ---- | ------------------------------------------------------------ |
| 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.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var names = ["status", "navigation"]; var names = ["status", "navigation"];
let promise = windowClass.setSystemBarEnable(names); let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
}); });
``` ```
### setSystemBarProperties ### setSystemBarProperties
...@@ -1191,32 +1420,32 @@ Sets the properties of the status bar and navigation bar in this window. This AP ...@@ -1191,32 +1420,32 @@ Sets the properties of the status bar and navigation bar in this window. This AP
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------------- | ------------------------------------------- | ---- | -------------------- | | ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var SystemBarProperties={ var SystemBarProperties={
statusBarColor: '#ff00ff', statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00', navigationBarColor: '#00ff00',
// The following properties are supported since API version 7. // The following properties are supported since API version 7.
isStatusBarLightIcon: true, isStatusBarLightIcon: true,
isNavigationBarLightIcon:false, isNavigationBarLightIcon:false,
// The following properties are supported since API version 8. // The following properties are supported since API version 8.
statusBarContentColor:'#ffffff', statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff' navigationBarContentColor:'#00ffff'
}; };
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}); });
``` ```
### setSystemBarProperties ### setSystemBarProperties
...@@ -1228,69 +1457,129 @@ Sets the properties of the status bar and navigation bar in this window. This AP ...@@ -1228,69 +1457,129 @@ Sets the properties of the status bar and navigation bar in this window. This AP
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------------- | ------------------------------------------- | ---- | -------------------- | | ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var SystemBarProperties={
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
// The following properties are supported since API version 7.
isStatusBarLightIcon: true,
isNavigationBarLightIcon:false,
// The following properties are supported since API version 8.
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> {
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});
```
### loadContent<sup>7+</sup> **Example**
loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void ```js
var SystemBarProperties={
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
// The following properties are supported since API version 7.
isStatusBarLightIcon: true,
isNavigationBarLightIcon:false,
// The following properties are supported since API version 8.
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> {
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
});
```
Loads content to this window. This API uses an asynchronous callback to return the result. ### setPreferredOrientation<sup>9+</sup>
setPreferredOrientation(orientation: Orientation, callback: AsyncCallback&lt;void&gt;): void
Sets the preferred orientation for this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------- | | ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation | [Orientation](#orientation9) | Yes | Orientation to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
var orientation = window.Orientation.AUTO_ROTATION;
windowClass.setPreferredOrientation(orientation, (err, data) => {
if (err.code) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data));
});
```
### setPreferredOrientation<sup>9+</sup>
setPreferredOrientation(orientation: Orientation): Promise&lt;void&gt;
Sets the preferred orientation for this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| Orientation | [Orientation](#orientation9) | Yes | Orientation to set. |
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var orientation = window.Orientation.AUTO_ROTATION;
let promise = windowClass.setPreferredOrientation(orientation);
promise.then((data)=> {
console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err));
});
```
### loadContent<sup>7+</sup>
loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
Loads content from a page to this window. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------- |
| path | string | Yes | Path of the page from which the content will be loaded.| | path | string | Yes | Path of the page from which the content will be loaded.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.loadContent("pages/page2/page2", (err, data) => { windowClass.loadContent("pages/page2/page2", (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}); });
``` ```
### loadContent<sup>7+</sup> ### loadContent<sup>7+</sup>
loadContent(path: string): Promise&lt;void&gt; loadContent(path: string): Promise&lt;void&gt;
Loads content to this window. This API uses a promise to return the result. Loads content from a page to this window. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1302,21 +1591,101 @@ Loads content to this window. This API uses a promise to return the result. ...@@ -1302,21 +1591,101 @@ Loads content to this window. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.loadContent("pages/page2/page2"); let promise = windowClass.loadContent("pages/page2/page2");
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
}); });
``` ```
### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
Loads content from a page associated with a local storage to this window. This API uses an asynchronous callback to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```ts
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
this.storage = new LocalStorage();
this.storage.setOrCreate("storageSimpleProp",121);
console.log('onWindowStageCreate');
windowStage.loadContent("pages/page2",this.storage,(err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
}
}
```
### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;
Loads content from a page associated with a local storage to this window. This API uses a promise to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```ts
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
this.storage = new LocalStorage();
this.storage.setOrCreate("storageSimpleProp",121);
console.log('onWindowStageCreate');
var windowClass = null;
let promise = windowStage.loadContent("pages/page2",this.storage);
promise.then((data)=> {
windowClass = data;
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
})
}
}
```
### isShowing<sup>7+</sup> ### isShowing<sup>7+</sup>
isShowing(callback: AsyncCallback&lt;boolean&gt;): void isShowing(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -1327,21 +1696,21 @@ Checks whether this window is displayed. This API uses an asynchronous callback ...@@ -1327,21 +1696,21 @@ Checks whether this window is displayed. This API uses an asynchronous callback
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------------- | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the window is displayed.| | callback | AsyncCallback&lt;boolean&gt; | 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
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ----------------------------------------------------- | | ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return whether the window is displayed.| | Promise&lt;boolean&gt; | Promise used to return the result. The value `true` means that this window is displayed, and `false` means the opposite.|
**Example** **Example**
```js ```js
let promise = windowClass.isShowing(); let promise = windowClass.isShowing();
promise.then((data)=> { promise.then((data)=> {
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));
}).catch((err)=>{ }).catch((err)=>{
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));
}); });
``` ```
### on('windowSizeChange')<sup>7+</sup> ### on('windowSizeChange')<sup>7+</sup>
...@@ -1378,19 +1747,18 @@ Enables listening for window size changes. ...@@ -1378,19 +1747,18 @@ Enables listening for window size changes.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- | | -------- | ------------------------------ | ---- | -------------------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| | type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
| callback | Callback&lt;[Size](#size)&gt; | Yes | Callback used to return the information. | | callback | Callback&lt;[Size](#size7)&gt; | Yes | Callback used to return the window size. |
**Example** **Example**
```js ```js
var type = 'windowSizeChange'; windowClass.on('windowSizeChange', (data) => {
windowClass.on(type, (data) => { console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); });
}); ```
```
### off('windowSizeChange')<sup>7+</sup> ### off('windowSizeChange')<sup>7+</sup>
...@@ -1404,61 +1772,109 @@ Disables listening for window size changes. ...@@ -1404,61 +1772,109 @@ Disables listening for window size changes.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- | | -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **windowSizeChange**, indicating the window size change event.| | type | string | Yes | Event type. The value is fixed at `windowSizeChange`, indicating the window size change event.|
| callback | Callback&lt;[Size](#size)&gt; | No | Callback used to return the information. | | callback | Callback&lt;[Size](#size)&gt; | No | Callback used to return the window size. |
**Example** **Example**
```js ```js
var type = 'windowSizeChange'; windowClass.off('windowSizeChange');
windowClass.off(type); ```
```
### on('systemAvoidAreaChange')<sup>7+</sup> ### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
on(type: 'systemAvoidAreaChange', callback: Callback&lt;AvoidArea&gt;): void on(type: 'systemAvoidAreaChange', callback: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
Enables listening for changes to the area where the window cannot be displayed. Enables listening for changes to the area where the window cannot be displayed.
> **NOTE**
>
> This API is deprecated since API version 9. Use [on('avoidAreaChange')](#onavoidareachange9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| 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&lt;[AvoidArea](#avoidarea)&gt; | Yes | Callback used to return the information. | | callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | Yes | Callback used to return the area. |
**Example** **Example**
```js ```js
var type = '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)); });
}); ```
```
### off('systemAvoidAreaChange')<sup>7+</sup> ### off('systemAvoidAreaChange')<sup>(deprecated)</sup>
off(type: 'systemAvoidAreaChange', callback?: Callback&lt;AvoidArea&gt;): void off(type: 'systemAvoidAreaChange', callback?: Callback&lt;[AvoidArea](#avoidarea7)&gt;): void
Disables listening for changes to the area where the window cannot be displayed. Disables listening for changes to the area where the window cannot be displayed.
> **NOTE**
>
> This API is deprecated since API version 9. Use [off('avoidAreaChange')](#offavoidareachange9) instead.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| 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&lt;[AvoidArea](#avoidarea)&gt; | No | Callback used to return the information. | | callback | Callback&lt;[AvoidArea](#avoidarea7)&gt; | No | Callback used to return the area. |
**Example** **Example**
```js ```js
var type = 'systemAvoidAreaChange'; windowClass.off('systemAvoidAreaChange');
windowClass.off(type); ```
```
### on('avoidAreaChange')<sup>9+</sup>
on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void
Enables listening for changes to the area where the window cannot be displayed.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- |------------------------------------------------------------------| ---- |--------------------------------------|
| 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&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | 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));
});
```
### off('avoidAreaChange')<sup>9+</sup>
off(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void
Disables listening for changes to the area where the window cannot be displayed.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- |-----------------------------------------------------------------------------|-----|------------------------------------|
| 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&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt; | 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.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| | type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
| callback | Callbacknumber&gt; | Yes | Callback used to return the information. | | callback | Callback<number&gt; | Yes | Callback used to return the current keyboard height. |
**Example** **Example**
```js ```js
var type = 'keyboardHeightChange'; windowClass.on('keyboardHeightChange', (data) => {
windowClass.on(type, (data) => { console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); });
}); ```
```
### off('keyboardHeightChange')<sup>7+</sup> ### off('keyboardHeightChange')<sup>7+</sup>
...@@ -1496,15 +1911,60 @@ Disables listening for keyboard height changes. ...@@ -1496,15 +1911,60 @@ Disables listening for keyboard height changes.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to listen for. The value is fixed at **keyboardHeightChange**, indicating the keyboard height change event.| | type | string | Yes | Event type. The value is fixed at `keyboardHeightChange`, indicating the keyboard height change event.|
| callback | Callback&lt;number&gt; | No | Callback used to return the information. | | callback | Callback&lt;number&gt; | No | Callback used to return the current keyboard height. |
**Example**
```js
windowClass.off('keyboardHeightChange');
```
### on('touchOutside')<sup>9+</sup>
on(type: 'touchOutside', callback: Callback&lt;void&gt;): void
Enables listening for click events outside this window.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
| callback | Callback<void&gt; | Yes | Callback used to Callback used to return the click event outside this window. |
**Example**
```js
windowClass.on('touchOutside', () => {
console.info('touch outside');
});
```
### off('touchOutside')<sup>9+</sup>
off(type: 'touchOutside', callback?: Callback&lt;void&gt;): void
Disables listening for click events outside this window.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at `touchOutside`, indicating the click event outside this window.|
| callback | Callback&lt;number&gt; | No | Callback used to Callback used to return the click event outside this window. |
**Example** **Example**
```js ```js
var type = 'keyboardHeightChange'; windowClass.off('touchOutside');
windowClass.off(type); ```
```
### isSupportWideGamut<sup>8+</sup> ### isSupportWideGamut<sup>8+</sup>
...@@ -1516,21 +1976,21 @@ Checks whether this window supports the wide color gamut mode. This API uses an ...@@ -1516,21 +1976,21 @@ Checks whether this window supports the wide color gamut mode. This API uses an
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------------- | | -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the wide color gamut mode is supported.| | callback | AsyncCallback&lt;boolean&gt; | 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
| Type | Description | | Type | Description |
| ---------------------- | ------------------------------------------------------------ | | ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return whether the wide color gamut mode is supported.| | Promise&lt;boolean&gt; | 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
let promise = windowClass.isSupportWideGamut(); let promise = 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
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | ------------ |
| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}) })
``` ```
### setColorSpace<sup>8+</sup> ### setColorSpace<sup>8+</sup>
...@@ -1594,26 +2054,26 @@ Sets this window to the wide or default color gamut mode. This API uses a promis ...@@ -1594,26 +2054,26 @@ Sets this window to the wide or default color gamut mode. This API uses a promis
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | -------------- |
| colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
}); });
``` ```
### getColorSpace<sup>8+</sup> ### getColorSpace<sup>8+</sup>
...@@ -1625,21 +2085,21 @@ Obtains the color gamut mode of this window. This API uses an asynchronous callb ...@@ -1625,21 +2085,21 @@ Obtains the color gamut mode of this window. This API uses an asynchronous callb
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | -------------------------- | | -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
| callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | Yes | Callback used to return the color gamut mode obtained.| | callback | AsyncCallback&lt;[ColorSpace](#colorspace)&gt; | 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
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ----------------------------------------- | | ---------------------------------------- | ------------------------------- |
| Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the color gamut mode obtained.| | Promise&lt;[ColorSpace](#colorspace)&gt; | Promise used to return the current color gamut mode.|
**Example** **Example**
```js ```js
let promise = windowClass.getColorSpace(); let promise = windowClass.getColorSpace();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setBackgroundColor ### setBackgroundColor
setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
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).
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1678,27 +2138,27 @@ Sets the background color for this window. This API uses an asynchronous callbac ...@@ -1678,27 +2138,27 @@ Sets the background color for this window. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var color = '#00ff33'; var color = '#00ff33';
windowClass.setBackgroundColor(color, (err, data) => { windowClass.setBackgroundColor(color, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
}); });
``` ```
### setBackgroundColor ### setBackgroundColor
setBackgroundColor(color: string): Promise&lt;void&gt; setBackgroundColor(color: string): Promise&lt;void&gt;
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).
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1706,25 +2166,25 @@ Sets the background color for this window. This API uses a promise to return the ...@@ -1706,25 +2166,25 @@ Sets the background color for this window. This API uses a promise to return the
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| 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`.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var color = '#00ff33'; var color = '#00ff33';
let promise = windowClass.setBackgroundColor(color); let promise = windowClass.setBackgroundColor(color);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setBrightness ### setBrightness
...@@ -1738,21 +2198,21 @@ Sets the screen brightness for this window. This API uses an asynchronous callba ...@@ -1738,21 +2198,21 @@ Sets the screen brightness for this window. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------------------------ | | ---------- | ------------------------- | ---- | ------------------------------------ |
| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var brightness = 1; var brightness = 1;
windowClass.setBrightness(brightness, (err, data) => { windowClass.setBrightness(brightness, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}); });
``` ```
### setBrightness ### setBrightness
...@@ -1766,25 +2226,25 @@ Sets the screen brightness for this window. This API uses a promise to return th ...@@ -1766,25 +2226,25 @@ Sets the screen brightness for this window. This API uses a promise to return th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------ | | ---------- | ------ | ---- | ------------------------------------ |
| brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value `1` indicates the brightest.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var brightness = 1; var brightness = 1;
let promise = windowClass.setBrightness(brightness); let promise = windowClass.setBrightness(brightness);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setDimBehind<sup>(deprecated)</sup> ### setDimBehind<sup>(deprecated)</sup>
...@@ -1794,7 +2254,7 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous ...@@ -1794,7 +2254,7 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1802,20 +2262,20 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous ...@@ -1802,20 +2262,20 @@ Sets the dimness of the window that is not on top. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------------------------- | ---- | -------------------------------------------------- | | -------------- | ------------------------- | ---- | -------------------------------------------------- |
| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.setDimBehind(0.5, (err, data) => { windowClass.setDimBehind(0.5, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data));
}); });
``` ```
### setDimBehind<sup>(deprecated)</sup> ### setDimBehind<sup>(deprecated)</sup>
...@@ -1825,7 +2285,7 @@ Sets the dimness of the window that is not on top. This API uses a promise to re ...@@ -1825,7 +2285,7 @@ Sets the dimness of the window that is not on top. This API uses a promise to re
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1833,24 +2293,24 @@ Sets the dimness of the window that is not on top. This API uses a promise to re ...@@ -1833,24 +2293,24 @@ Sets the dimness of the window that is not on top. This API uses a promise to re
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | -------------------------------------------------- | | -------------- | ------ | ---- | -------------------------------------------------- |
| dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value **1** indicates the dimmest.| | dimBehindValue | number | Yes | Dimness of the window to set. The value ranges from 0 to 1. The value `1` indicates the dimmest.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.setDimBehind(0.5); let promise = windowClass.setDimBehind(0.5);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setFocusable<sup>7+</sup> ### setFocusable<sup>7+</sup>
...@@ -1865,20 +2325,20 @@ Sets whether this window can gain focus. This API uses an asynchronous callback ...@@ -1865,20 +2325,20 @@ Sets whether this window can gain focus. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | ---------------------------- | | ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean | Yes | Whether the window can gain focus.| | isFocusable | boolean | Yes | Whether the window can gain focus.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var isFocusable= true; var isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => { windowClass.setFocusable(isFocusable, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}); });
``` ```
### setFocusable<sup>7+</sup> ### setFocusable<sup>7+</sup>
...@@ -1896,21 +2356,21 @@ Sets whether this window can gain focus. This API uses a promise to return the r ...@@ -1896,21 +2356,21 @@ Sets whether this window can gain focus. This API uses a promise to return the r
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isFocusable= true; var isFocusable= true;
let promise = windowClass.setFocusable(isFocusable); let promise = windowClass.setFocusable(isFocusable);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setKeepScreenOn ### setKeepScreenOn
...@@ -1925,20 +2385,52 @@ Sets whether to keep the screen always on. This API uses an asynchronous callbac ...@@ -1925,20 +2385,52 @@ Sets whether to keep the screen always on. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------------------------- | ---- | ------------------------ | | -------------- | ------------------------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
var isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
});
```
### setKeepScreenOn
setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
Sets whether to keep the screen always on. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isKeepScreenOn = true; var isKeepScreenOn = true;
windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
if (err.code) { promise.then((data) => {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
return; }).catch((err)=>{
} console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); });
}); ```
```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
...@@ -1948,7 +2440,7 @@ Sets whether the area outside the subwindow is touchable. This API uses an async ...@@ -1948,7 +2440,7 @@ Sets whether the area outside the subwindow is touchable. This API uses an async
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -1956,20 +2448,20 @@ Sets whether the area outside the subwindow is touchable. This API uses an async ...@@ -1956,20 +2448,20 @@ Sets whether the area outside the subwindow is touchable. This API uses an async
| 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.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
windowClass.setOutsideTouchable(true, (err, data) => { windowClass.setOutsideTouchable(true, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
}) })
``` ```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
...@@ -1979,7 +2471,7 @@ Sets whether the area outside the subwindow is touchable. This API uses a promis ...@@ -1979,7 +2471,7 @@ Sets whether the area outside the subwindow is touchable. This API uses a promis
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is deprecated since API version 9.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
...@@ -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.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
let promise = windowClass.setOutsideTouchable(true); let promise = windowClass.setOutsideTouchable(true);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setKeepScreenOn
setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
Sets whether to keep the screen always on. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.|
**Return value**
| Type | Description |
| ------------------- | ----------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Example**
```js
var isKeepScreenOn= true;
let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
promise.then((data)=> {
console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
});
```
### setPrivacyMode<sup>7+</sup> ### setPrivacyMode<sup>7+</sup>
...@@ -2051,21 +2511,21 @@ Sets whether this window is in privacy mode. This API uses an asynchronous callb ...@@ -2051,21 +2511,21 @@ Sets whether this window is in privacy mode. This API uses an asynchronous callb
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ------------------------- | ---- | -------------------- | | ------------- | ------------------------- | ---- | -------------------- |
| isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var isPrivacyMode = true; var isPrivacyMode = true;
windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data));
}); });
``` ```
### setPrivacyMode<sup>7+</sup> ### setPrivacyMode<sup>7+</sup>
...@@ -2083,21 +2543,21 @@ Sets whether this window is in privacy mode. This API uses a promise to return t ...@@ -2083,21 +2543,21 @@ Sets whether this window is in privacy mode. This API uses a promise to return t
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isPrivacyMode = true; var isPrivacyMode = true;
let promise = windowClass.setPrivacyMode(isPrivacyMode); let promise = windowClass.setPrivacyMode(isPrivacyMode);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setTouchable<sup>7+</sup> ### setTouchable<sup>7+</sup>
...@@ -2112,21 +2572,21 @@ Sets whether this window is touchable. This API uses an asynchronous callback to ...@@ -2112,21 +2572,21 @@ Sets whether this window is touchable. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | -------------------- | | ----------- | ------------------------- | ---- | -------------------- |
| isTouchable | boolean | Yes | Whether the window is touchable.| | isTouchable | boolean | Yes | Whether the window is touchable.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
var isTouchable = true; var isTouchable = true;
windowClass.setTouchable(isTouchable, (err, data) => { windowClass.setTouchable(isTouchable, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
}); });
``` ```
### setTouchable<sup>7+</sup> ### setTouchable<sup>7+</sup>
...@@ -2144,30 +2604,97 @@ Sets whether this window is touchable. This API uses a promise to return the res ...@@ -2144,30 +2604,97 @@ Sets whether this window is touchable. This API uses a promise to return the res
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ----------------------------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var isTouchable = true; var isTouchable = true;
let promise = windowClass.setTouchable(isTouchable); let promise = windowClass.setTouchable(isTouchable);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)) console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setForbidSplitMove<sup>9+</sup>
setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | -------------------- |
| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
var isForbidSplitMove = true;
windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => {
if (err.code) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data));
});
```
### setForbidSplitMove<sup>9+</sup>
setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------- | ---- | -------------------- |
| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var isForbidSplitMove = true;
let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
promise.then((data)=> {
console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err));
});
```
## WindowStageEventType<sup>9+</sup> ## WindowStageEventType<sup>9+</sup>
Describes the lifecycle of a window stage. Describes the lifecycle of a window stage.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ---------- | ------ | -------- | | ---------- | ------ | ---------- |
| 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.
### getMainWindow<sup>9+</sup>
getMainWindow(callback: AsyncCallback&lt;Window&gt;): void
Obtains the main window of this window stage. This API uses an asynchronous callback to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the main window.|
**Example**
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
var windowClass = null;
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
});
}
}
```
### getMainWindow<sup>9+</sup> ### getMainWindow<sup>9+</sup>
getMainWindow(): Promise&lt;Window&gt; getMainWindow(): Promise&lt;Window&gt;
Obtains the main window of this window stage. This API uses a promise to return the result. Obtains the main window of this window stage. This API uses a promise to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ---------------------------------------------------------- | | -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the main window.| | Promise&lt;[Window](#window)&gt; | Promise used to return the main window.|
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var windowClass = null; console.log('onWindowStageCreate');
let promise = windowStage.getMainWindow(); var windowClass = null;
promise.then((data)=> { let promise = windowStage.getMainWindow();
windowClass = data; promise.then((data)=> {
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)) windowClass = data;
}).catch((err)=>{ console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); }).catch((err)=>{
}); console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
} });
} }
``` }
```
### createSubWindow<sup>9+</sup>
### getMainWindow<sup>9+</sup> createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
getMainWindow(callback: AsyncCallback&lt;Window&gt;): void Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result.
Obtains the main window of this window stage. This API uses an asynchronous callback to return the result. This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | --------------------------------------- | | -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the main window.| | name | String | Yes | Name of the subwindow. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow.|
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var windowClass = null; console.log('onWindowStageCreate');
windowStage.getMainWindow((err, data) => { var windowClass = null;
if (err.code) { windowStage.createSubWindow("mySubWindow", (err, data) => {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); if (err.code) {
return; console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
} return;
windowClass = data; }
console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); windowClass = data;
}); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
} windowClass.resetSize(500, 1000);
} });
``` }
}
```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
createSubWindow(name: string): Promise&lt;Window&gt; createSubWindow(name: string): Promise&lt;Window&gt;
Creates a subwindow for this window stage. This API uses a promise to return the result. Creates a subwindow for this window stage. This API uses a promise to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -2258,159 +2830,215 @@ Creates a subwindow for this window stage. This API uses a promise to return the ...@@ -2258,159 +2830,215 @@ Creates a subwindow for this window stage. This API uses a promise to return the
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------------- | | -------------------------------- | ------------------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow created.| | Promise&lt;[Window](#window)&gt; | Promise used to return the subwindow.|
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var windowClass = null; console.log('onWindowStageCreate');
let promise = windowStage.createSubWindow("mySubWindow"); var windowClass = null;
promise.then((data)=> { let promise = windowStage.createSubWindow("mySubWindow");
windowClass = data; promise.then((data)=> {
console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data)) windowClass = data;
}).catch((err)=>{ console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
console.error('Failed to create sub window. Cause: ' + JSON.stringify(err)); }).catch((err)=>{
}) console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
} })
} }
``` }
```
### getSubWindow<sup>9+</sup>
### createSubWindow<sup>9+</sup> getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void Obtains all the subwindows of this window stage. This API uses an asynchronous callback to return the result.
Creates a subwindow for this window stage. This API uses an asynchronous callback to return the result. This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| name | String | Yes | Name of the subwindow. | | callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | Yes | Callback used to return all the subwindows.|
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the subwindow created.|
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var windowClass = null; console.log('onWindowStageCreate');
windowStage.createSubWindow("mySubWindow", (err, data) => { var windowClass = null;
if (err.code) { windowStage.getSubWindow((err, data) => {
console.error('Failed to create sub window. Cause: ' + JSON.stringify(err)); if (err.code) {
return; console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
} return;
windowClass = data; }
console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data)); windowClass = data;
windowClass.resetSize(500, 1000); console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
}); });
} }
} }
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt; getSubWindow(): Promise&lt;Array&lt;Window&gt;&gt;
Obtains all the subwindows of this window stage. This API uses a promise to return the result. Obtains all the subwindows of this window stage. This API uses a promise to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------------- | ------------------------------------------------------------ | | --------------------------------------------- | ---------------------------------------------------- |
| Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.| | Promise&lt;Array&lt;[Window](#window)&gt;&gt; | Promise used to return all the subwindows.|
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var windowClass = null; console.log('onWindowStageCreate');
let promise = windowStage.getSubWindow(); var windowClass = null;
promise.then((data)=> { let promise = windowStage.getSubWindow();
windowClass = data; promise.then((data)=> {
console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data)) windowClass = data;
}).catch((err)=>{ console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data));
console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err)); }).catch((err)=>{
}) console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err));
} })
} }
``` }
```
### loadContent<sup>9+</sup>
### getSubWindow<sup>9+</sup> loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void 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. This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;Array&lt;[Window](#window)&gt;&gt; | 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&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); storage : LocalStorage
var windowClass = null; onWindowStageCreate(windowStage) {
windowStage.getSubWindow((err, data) => { this.storage = new LocalStorage();
if (err.code) { this.storage.setOrCreate("storageSimpleProp",121);
console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err)); console.log('onWindowStageCreate');
return; windowStage.loadContent("pages/page2",this.storage,(err, data) => {
} if (err.code) {
windowClass = data; console.error('Failed to load the content. Cause:' + JSON.stringify(err));
console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data)); return;
}); }
} console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
} });
``` }
}
```
### loadContent<sup>9+</sup>
loadContent(path: string, storage?: LocalStorage): Promise&lt;void&gt;
Loads content from a page associated with a local storage to the main window in this window stage. This API uses a promise to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
| 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.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
storage : LocalStorage
onWindowStageCreate(windowStage) {
this.storage = new LocalStorage();
this.storage.setOrCreate("storageSimpleProp",121);
console.log('onWindowStageCreate');
var windowClass = null;
let promise = windowStage.loadContent("pages/page2",this.storage);
promise.then((data)=> {
windowClass = data;
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
})
}
}
```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
Loads content to this window stage. This API uses an asynchronous callback to return the result. Loads content from a page to this window stage. This API uses an asynchronous callback to return the result.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Coretype with the value **windowSizeChange** **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------- | | -------- | ------------------------- | ---- | -------------------- |
| path | string | Yes | Path of the page from which the content will be loaded.| | path | string | Yes | Path of the page from which the content will be loaded.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the execution result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
windowStage.loadContent("pages/page2", (err, data) => { console.log('onWindowStageCreate');
if (err.code) { windowStage.loadContent("pages/page2", (err, data) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); if (err.code) {
return; console.error('Failed to load the content. Cause:' + JSON.stringify(err));
} return;
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) }
}); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
} });
} }
``` }
```
### on('windowStageEvent')<sup>9+</sup> ### on('windowStageEvent')<sup>9+</sup>
...@@ -2418,28 +3046,30 @@ on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt; ...@@ -2418,28 +3046,30 @@ on(eventType: 'windowStageEvent', callback: Callback&lt;WindowStageEventType&gt;
Enables listening for window stage lifecycle changes. Enables listening for window stage lifecycle changes.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| | type | string | Yes | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes | Callback used to return the information. | | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | Yes | Callback used to return the window stage lifecycle state. |
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var type = 'windowStageEvent'; console.log('onWindowStageCreate');
windowStage.on(type, (data) => { windowStage.on('windowStageEvent', (data) => {
console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
}); });
} }
} }
``` ```
### off('windowStageEvent')<sup>9+</sup> ### off('windowStageEvent')<sup>9+</sup>
...@@ -2447,33 +3077,61 @@ off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&g ...@@ -2447,33 +3077,61 @@ off(eventType: 'windowStageEvent', callback?: Callback&lt;WindowStageEventType&g
Disables listening for window stage lifecycle changes. Disables listening for window stage lifecycle changes.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of event to listen for. The value is fixed at **windowStageEvent**, indicating the window stage lifecycle change event.| | type | string | Yes | Event type. The value is fixed at `windowStageEvent`, indicating the window stage lifecycle change event.|
| callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No | Callback used to return the information. | | callback | Callback&lt;[WindowStageEventType](#windowstageeventtype9)&gt; | No | Callback used to return the window stage lifecycle state. |
**Example** **Example**
```ts ```ts
class myAbility extends Ability { import Ability from '@ohos.application.Ability';
onWindowStageCreate(windowStage) { class myAbility extends Ability {
console.log('onWindowStageCreate'); onWindowStageCreate(windowStage) {
var type = 'windowStageEvent'; console.log('onWindowStageCreate');
windowStage.off(type); windowStage.off('windowStageEvent');
} }
} }
``` ```
### disableWindowDecor()<sup>9+</sup>
disableWindowDecor(): void
Disables window decorators.
### setShowOnLockScreen('showOnLockScreen')<sup>9+</sup> This type can be used only in the stage model.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Example**
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('disableWindowDecor');
windowStage.disableWindowDecor();
}
}
```
### setShowOnLockScreen()<sup>9+</sup>
setShowOnLockScreen(showOnLockScreen: boolean): void setShowOnLockScreen(showOnLockScreen: boolean): void
Sets whether to display the window of the application on the lock screen. Sets whether to display the window of the application on the lock screen.
This API can be used only in the stage model.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters** **Parameters**
...@@ -2485,6 +3143,7 @@ Sets whether to display the window of the application on the lock screen. ...@@ -2485,6 +3143,7 @@ Sets whether to display the window of the application on the lock screen.
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册