diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index 3493f9813ba2c98d1e62dd6526511fa832c1bbb9..c3ec8f7fb3b13c935a4d3dc23f4f9cf8b96dfa12 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -1,2280 +1,2159 @@ -# Window +# Window ->![](../../public_sys-resources/icon-note.gif) **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. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. -## Modules to Import +## Modules to Import ``` import window from '@ohos.window'; ``` -## System Capabilities -SystemCapability.WindowManager.WindowManager.Core +## WindowType7+ +Enumerates the window types. -## Required Permissions +**System capability**: SystemCapability.WindowManager.WindowManager.Core -ohos.permission.SYSTEM\_FLOAT\_WINDOW +| Name | Default Value| Description | +| ----------------- | ------ | ------------------ | +| TYPE_APP | 0 | Application subwindow. | +| TYPE_SYSTEM_ALERT | 1 | System alert window.| -## SystemBarProperties +## AvoidAreaType7+ + +Enumerates the types of the area where the window cannot be displayed. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Default Value| Description | +| ----------- | ------ | ------------------ | +| TYPE_SYSTEM | 0 | Default area of the system.| +| TYPE_CUTOUT | 1 | Notch. | + +## WindowMode7+ + +Enumerates the window modes of an application. + +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Default 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.| + +## SystemBarProperties Describes the properties of the status bar and navigation bar. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

statusBarColor

-

string

-

Yes

-

Yes

-

Color of the status bar. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.

-

isStatusBarLightIcon7+

-

boolean

-

Yes

-

Yes

-

Whether any icon on the status bar is highlighted.

-

navigationBarColor

-

string

-

Yes

-

Yes

-

Color of the navigation bar. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.

-

isNavigationBarLightIcon7+

-

boolean

-

Yes

-

Yes

-

Whether any icon on the navigation bar is highlighted.

-
- -## Rect7+ +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| 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, for example, **\#00FF00** or **\#FF00FF00**.| +| isStatusBarLightIcon7+ | boolean | No | Yes | Whether any icon on the status bar is highlighted. | +| statusBarContentColor8+ | 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, for example, **\#00FF00** or **\#FF00FF00**.| +| isNavigationBarLightIcon7+ | boolean | No | No | Whether any icon on the navigation bar is highlighted. | +| navigationBarContentColor8+ | string | No | Yes | Color of the text on the navigation bar. | + +## SystemBarRegionTint8+ + +Describes the callback for a single system bar. + +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Readable| Writable| Description | +| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | +| type | [WindowType](#windowtype) | Yes | Yes | Type of the system bar whose properties are changed. Only the navigation bar and status bar are supported.| +| isEnable | boolean | Yes | Yes | Whether the system bar is displayed. | +| 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, for example, **\#00FF00** or **\#FF00FF00**.| +| contentColor | string | Yes | Yes | Color of the text on the system bar. | + +## SystemBarTintState8+ + +Describes the callback for the current system bar. + +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Readable| Writable| Description | +| ---------- | -------------------------------------------------- | ---- | ---- | -------------------------- | +| displayId | number | Yes | No | ID of the current physical screen. | +| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | Yes | Yes | All system bar information changed.| + +## Rect7+ Describes a rectangle. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

left

-

number

-

Yes

-

Yes

-

Left boundary of the rectangle.

-

top

-

number

-

Yes

-

Yes

-

Top boundary of the rectangle.

-

width

-

number

-

Yes

-

Yes

-

Width of the rectangle.

-

height

-

number

-

Yes

-

Yes

-

Height of the rectangle.

-
- -## AvoidArea7+ +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| ------ | -------- | ---- | ---- | ------------------ | +| left | number | Yes | Yes | Left boundary of the rectangle.| +| top | number | Yes | Yes | Top boundary of the rectangle.| +| width | number | Yes | Yes | Width of the rectangle. | +| height | number | Yes | Yes | Height of the rectangle. | + +## AvoidArea7+ Describes the area where the window cannot be displayed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

leftRect

-

Rect

-

Yes

-

Yes

-

Rectangle on the left of the screen.

-

topRect

-

Rect

-

Yes

-

Yes

-

Rectangle at the top of the screen.

-

rightRect

-

Rect

-

Yes

-

Yes

-

Rectangle on the right of the screen.

-

bottomRect

-

Rect

-

Yes

-

Yes

-

Rectangle at the bottom of the screen.

-
- -## Size7+ +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Readable| Writable| Description | +| ---------- | ------------- | ---- | ---- | ------------------ | +| leftRect | [Rect](#rect) | Yes | Yes | Rectangle on the left 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.| +| bottomRect | [Rect](#rect) | Yes | Yes | Rectangle at the bottom of the screen.| + +## Size7+ Describes the window size. - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

width

-

number

-

Yes

-

Yes

-

Window width.

-

height

-

number

-

Yes

-

Yes

-

Window height.

-
- -## WindowProperties +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| ------ | -------- | ---- | ---- | ---------- | +| width | number | Yes | Yes | Window width.| +| height | number | Yes | Yes | Window height.| + +## WindowProperties Describes the window properties. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

windowRect7+

-

Rect

-

Yes

-

No

-

Window size.

-

type7+

-

WindowType

-

Yes

-

No

-

Window type.

-

brightness

-

number

-

Yes

-

Yes

-

Screen brightness. The value ranges from 0 to 1. The value 1 indicates the maximum brightness.

-

isTransparent7+

-

boolean

-

Yes

-

Yes

-

Whether the window is transparent. The default value is false.

-

isFullScreen

-

boolean

-

Yes

-

Yes

-

Whether the window is displayed in full screen mode. The default value is false.

-

isKeepScreenOn

-

boolean

-

Yes

-

Yes

-

Whether the screen is always on. The default value is false.

-

dimBehindValue7+

-

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.

-

isLayoutFullScreen7+

-

boolean

-

Yes

-

Yes

-

Whether the window layout is in full-screen mode (whether the window is immersive). The default value is false.

-

focusable7+

-

boolean

-

Yes

-

Yes

-

Whether the window can gain focus. The default value is true.

-

touchable7+

-

boolean

-

Yes

-

Yes

-

Whether the window is touchable. The default value is true.

-

isPrivacyMode7+

-

boolean

-

Yes

-

Yes

-

Whether the window is in privacy mode. The default value is false.

-

isRoundCorner7+

-

boolean

-

Yes

-

Yes

-

Whether the window has rounded corners.

-
- -## SplitScreenBoundsInfo7+ - -Describes information about the split-screen boundary. - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

splitMode7+

-

number

-

Split-screen mode.

-

primaryBounds

-

Rect

-

Primary window boundary information, which is in the format of a Rect instance.

-

secondaryBounds

-

Rect

-

Secondary window boundary information, which is in the format of a Rect instance.

-
- -## window.getTopWindow - -getTopWindow\(callback: AsyncCallback\): void - -Obtains a **Window** instance. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<Window>

-

Yes

-

Callback used to return the current Window object.

-
- -- Example - - ``` - window.getTopWindow((err, data) => { - if (err) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); - windowClass = data; - }); - ``` - - -## window.create7+ - -create\(id: string, type: WindowType, callback: AsyncCallback\): void - -Creates a subwindow. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

id

-

string

-

Yes

-

Window ID.

-

type

-

WindowType

-

Yes

-

Window type.

-

callback

-

AsyncCallback<Window>

-

Yes

-

Callback used to return the current Window object.

-
- -- Example +**System capability**: SystemCapability.WindowManager.WindowManager.Core -``` - window.create("first", 1, (err, data) => { - windowClass = data; - if (err) { - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('SubWindow created. Data: ' + JSON.stringify(data)) - windowClass.resetSize(500, 1000); - windowClass.setOutsideTouchable(true); - windowClass.loadContent("pages/index/index", (err, data) => { +| Name | Type | Readable| Writable| Description | +| ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | +| windowRect7+ | [Rect](#rect) | Yes | Yes | Window size. | +| type7+ | [WindowType](#windowtype) | Yes | Yes | Window type. | +| isFullScreen | boolean | Yes | Yes | Whether the window is displayed in full screen mode. The default value is **false**. | +| isLayoutFullScreen7+ | boolean | Yes | Yes | Whether the window layout is in full-screen mode (whether the window is immersive). The default value is **false**. | +| focusable7+ | boolean | Yes | No | Whether the window can gain focus. The default value is **true**. | +| touchable7+ | 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.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| dimBehindValue7+ | 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.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| isKeepScreenOn | boolean | Yes | Yes | Whether the screen is always on. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| isPrivacyMode7+ | boolean | Yes | Yes | Whether the window is in privacy mode. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| isRoundCorner7+ | boolean | Yes | Yes | Whether the window has rounded corners.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| +| isTransparent7+ | boolean | Yes | Yes | Whether the window is transparent. The default value is **false**.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| + +## ColorSpace8+ + +Describes the color gamut mode. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Default Value| Description | +| ---------- | ------ | -------------- | +| DEFAULT | 0 | Default color gamut mode.| +| WIDE_GAMUT | 1 | Wide color gamut mode. | + +## window.create7 + +create(id: string, type: WindowType, callback: AsyncCallback<Window>): void + +Creates a subwindow. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | -------------------------------------- | ---- | -------------------------- | + | id | string | Yes | Window ID. | + | type | [WindowType](#windowtype) | Yes | Window type. | + | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the subwindow created.| + +- Example + + ``` + var windowClass = null; + window.create("first", window.WindowType.TYPE_APP, (err, data) => { + if (err.code) { + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('SubWindow created. Data: ' + JSON.stringify(data)) + windowClass.resetSize(500, 1000); + }); + ``` + +## window.create7 + +create(id: string, type: WindowType): Promise<Window> + +Creates a subwindow. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------------------------- | ---- | ---------- | + | id | string | Yes | Window ID. | + | type | [WindowType](#windowtype) | Yes | Window type.| + +- Return value + + | Type | Description | + | -------------------------------- | ------------------------------------------------- | + | Promise<[Window](#window)> | Promise used to return the subwindow created.| + +- Example + + ``` + var windowClass = null; + let promise = window.create("first", window.WindowType.TYPE_APP); + promise.then((data)=> { + windowClass = data; + console.info('SubWindow created. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); }); -}) -``` + ``` -## window.find7+ - -find\(id: string, callback: AsyncCallback\): void - -Finds a subwindow. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

id

-

string

-

Yes

-

Window ID.

-

callback

-

AsyncCallback<Window>

-

Yes

-

Callback used to return the current Window object.

-
- -- Example - - ``` - window.find("first", (err, data) => { - if (err) { - console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('SubWindow found. Data: ' + JSON.stringify(data)) +## window.create8+ + +create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void + +Creates a system window when the context is [ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-service-extension-context.md). This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | Yes | Current application context, which is the base class of **ServiceExtensionContext**.| + | id | string | Yes | Window ID. | + | type | [WindowType](#windowtype) | Yes | Window type. | + | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the system window created. | + +- Example + + ``` + var windowClass = null; + window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { + if (err.code) { + console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); + return; + } windowClass = data; - }) - ``` - - -## window.getAbilityWindowMode7+ - -getAbilityWindowMode\(callback: AsyncCallback\): void - -Obtains the mode of this window. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<WindowMode>

-

Yes

-

Callback used to return the window mode.

-
- -- Example - - ``` - window.getAbilityWindowMode((err, data) => { - if (err) { - console.error('Failed to obtain the window mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window mode obtained. Data:' + JSON.stringify(data)) - - }); - ``` - - -## window.getSplitScreenBounds7+ - -getSplitScreenBounds\(splitRatio: SplitRatio, callback: AsyncCallback\): void - -Obtains the position and area of multiple windows in split-screen mode. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

splitRatio

-

SplitRatio

-

Yes

-

Screen split ratio. The default ratio is 1:1. The value 1 indicates the ratio 1:2, and the value 2 indicates the ratio 2:1.

-

callback

-

AsyncCallback<SplitScreenBoundsInfo>

-

Yes

-

Callback used to return a SplitScreenBoundsInfo object that contains the split-screen boundary information.

-
- -- Example - - ``` - var splitRatio = '1:1'; - window.getSplitScreenBounds(splitRatio, (err, data) => { - if (err) { - console.error('Failed to obtain the split-screen boundary information. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Split-screen boundary information obtained. Data: ' + JSON.stringify(data)) - - }); - ``` - - -## window.isFloatingAbilityWindowVisible7+ - -isFloatingAbilityWindowVisible\(callback:AsyncCallback\): void - -Checks whether the floating window is visible. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to indicate whether the floating window is visible.

-
- -- Example - - ``` - window.isFloatingAbilityWindowVisible( (err, data) => { - if (err) { - console.error('Failed to check whether the floating window is visible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the floating window is visible. Data:' + JSON.stringify(data)) - - }); - ``` - - -## window.setSplitBarVisibility7+ - -setSplitBarVisibility\(isVisibility: boolean, callback: AsyncCallback\): void - -Sets whether the split-screen divider is visible. - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

isVisibility

-

boolean

-

Whether to display the divider. The value true means to display the divider, and false means the opposite.

-

callback

-

AsyncCallback<void>

-

Callback used to return the execution result.

-
- -- Example - - ``` - var isVisibility = false; - window.setSplitBarVisibility(isVisibility , (err, data) => { - if (err) { - console.error('Failed to set the divider to be invisible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the divider to be invisible. Data:' + JSON.stringify(data)) - }); - ``` - - -## WindowType7+ - -Window type. - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

TYPE_APP

-

0

-

Application window.

-

TYPE_SYSTEM_ALERT

-

1

-

System pop-up window.

-
- -## AvoidAreaType7+ - -Describes the type of the area where the window cannot be displayed. - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

TYPE_SYSTEM

-

0

-

Default area of the system.

-

TYPE_CUTOUT

-

1

-

Notch.

-
- -## WindowMode7+ - -Describes the window mode of an application. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default 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.

-
- -## splitMode7+ - -Describes the split-screen mode. - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

VERTICAL

-

0

-

Vertical split-screen mode.

-

HORIZONTAL

-

1

-

Horizontal split-screen mode.

-
- -## Window - -In the following API examples, you must use [getTopWindow\(\)](#section39061940191) to obtain a **Window** instance and then call the corresponding methods based on this instance. - -## setBrightness - -setBrightness\(brightness:number, callback: AsyncCallback\): void - -Sets the brightness for this window. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

brightness

-

number

-

Yes

-

Brightness to set, which ranges from 0 to 1. The value 1 indicates the brightest.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var brightness = 10; - windowClass.setBrightness(brightness, (err, data) => { - if (err) { - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); - }); - ``` - - -## setBackgroundColor - -setBackgroundColor\(color: string, callback: AsyncCallback\): void - -Sets the background color for this window. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

color

-

string

-

Yes

-

Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var color = '#00ff33'; - windowClass.setBackgroundColor(color, (err, data) => { - if (err) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); - }); - ``` - - -## setTransparent7+ - -setTransparent\(isTransparent: boolean, callback: AsyncCallback\): void - -Sets whether this window is transparent. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isTransparent

-

boolean

-

Yes

-

Whether the window is transparent.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isTransparent = true; - windowClass.setTransparent(isTransparent, (err, data) => { - if (err) { - console.error('Failed to set the window to be transparent. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be transparent. Data: ' + JSON.stringify(data)) - }); - ``` - - -## setFullScreen - -setFullScreen\(isFullScreen: boolean, callback: AsyncCallback\): void - -Sets whether to enable the full-screen mode for this window. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isFullScreen

-

boolean

-

Yes

-

Whether to enable the full-screen mode.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isFullScreen = true; - windowClass.setFullScreen(isFullScreen, (err, data) => { - if (err) { - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); - }); - ``` - - -## setKeepScreenOn - -setKeepScreenOn\(isKeepScreenOn: boolean, callback: AsyncCallback\): void - -Sets whether to keep the screen always on. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isKeepScreenOn

-

boolean

-

Yes

-

Whether to keep the screen always on.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isKeepScreenOn = true; - windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { - if (err) { - 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)); - }); - ``` + console.info('Window created. Data: ' + JSON.stringify(data)) + windowClass.resetSize(500, 1000); + }); + ``` -### setWindowType7+ +## window.create8+ -setWindowType(type: WindowType, callback: AsyncCallback<void>): void +create(ctx: Context, id: string, type: WindowType): Promise<Window> -Sets the window type. +Creates a system window when the context is [ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-service-extension-context.md). This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core - Parameters - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------- | --------- | ---------------------------------------- | - | type | [WindowType](#section099619567453) | Yes | Window type. | - | callback | AsyncCallback<void> | Yes | Callback used to return the window type. | + | Name| Type | Mandatory| Description | + | ------ | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | Yes | Current application context, which is the base class of **ServiceExtensionContext**.| + | id | string | Yes | Window ID. | + | type | [WindowType](#windowtype) | Yes | Window type. | + +- Return value + | Type | Description | + | -------------------------------- | ----------------------------------------------- | + | Promise<[Window](#window)> | Promise used to return the system window created.| - Example + ``` - var type = window.TYPE_APP; - windowClass.setWindowType(type, (err, data) => { - if (err) { - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) + var windowClass = null; + let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); + promise.then((data)=> { + windowClass = data; + console.info('Window created. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); + }); + ``` + +## window.find7+ + +find(id: string, callback: AsyncCallback<Window>): void + +Finds a window based on the ID. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | -------------------------------------- | ---- | ---------------------------- | + | id | string | Yes | Window ID. | + | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the window found.| + +- Example + + ``` + var windowClass = null; + window.find("alertWindow", (err, data) => { + if (err.code) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)) }); ``` +## window.find7+ -## setDimBehind7+ - -setDimBehind\(dimBehindValue: number, callback: AsyncCallback\): void - -Sets the dimness of the window that is not on top. - -- Parameters - - - - - - - - - - - - - - - - - - - -

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.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.setDimBehind(0.5, (err, data) => { - if (err) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); - }); - ``` - - -## setLayoutFullScreen7+ - -setLayoutFullScreen\(isLayoutFullScreen: boolean, callback: AsyncCallback\): void - -Sets whether the window layout is in full-screen mode. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isLayoutFullScreen

-

boolean

-

Yes

-

Whether the window layout is in full-screen mode.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isLayoutFullScreen= true; - windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { - if (err) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window layout to full-screen mode. Data:' + JSON.stringify(data)); - }); - ``` - - -## setFocusable7+ - -setFocusable\(isFocusable: boolean, callback: AsyncCallback\): void - -Sets whether this window can gain focus. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isFocusable

-

boolean

-

Yes

-

Whether the window can gain focus.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isFocusable= true; - windowClass.setFocusable(isFocusable, (err, data) => { - if (err) { - console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); - }); - ``` - - -## setTouchable7+ - -setTouchable\(isTouchable: boolean, callback: AsyncCallback\): void - -Sets whether this window is touchable. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isTouchable

-

boolean

-

Yes

-

Whether the window is touchable.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isTouchable = true; - windowClass.setTouchable(isTouchable, (err, data) => { - if (err) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); - - }); - ``` - - -## setPrivacyMode7+ - -setPrivacyMode\(isPrivacyMode: boolean, callback: AsyncCallback\): void - -Sets whether this window is in privacy mode. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

isPrivacyMode

-

boolean

-

Yes

-

Whether the window is in privacy mode.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var isPrivacyMode = true; - windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { - if (err) { - console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); - - }); - ``` - - -## setSystemBarEnable7+ - -setSystemBarEnable\(names: Array, callback: AsyncCallback\): void - -Sets whether to display the status bar and navigation bar in this window. - -- Parameters - - - - - - - - - - - - - - - - - - - -

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"].

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var names = ["status", "navigation"]; - windowClass.setSystemBarEnable(names, (err, data) => { - if (err) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); - }); - ``` - - -## setSystemBarProperties - -setSystemBarProperties\(systemBarProperties: SystemBarProperties, callback: AsyncCallback\): void - -Sets the properties of the status bar and navigation bar in this window. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

SystemBarProperties

-

SystemBarProperties

-

Yes

-

Properties of the status bar and navigation bar to set.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - var SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - // The following properties are supported since API version 7. - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false - }; - windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { - if (err) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); - }); - ``` - - -## getProperties - -getProperties\(callback: AsyncCallback\): void - -Obtains the properties of this window. This method uses an asynchronous callback to return the window properties. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<WindowProperties>

-

Yes

-

Callback used to return the window properties.

-
- -- Example - - ``` - windowClass.getProperties((err, data) => { - if (err) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); - }); - ``` - - -## getAvoidArea7+ - -getAvoidArea\(type: AvoidAreaType, callback: AsyncCallback\): void - -Obtains the area where this window cannot be displayed, for example, the system bar area and notch area. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

AvoidAreaType

-

Yes

-

Type of the area. TYPE_SYSTEM indicates the default area of the system. TYPE_CUTOUT indicates the notch area.

-

callback

-

AsyncCallback<AvoidArea>

-

Yes

-

Callback used to return the area.

-
- -- Example - - ``` - var type = window.AvoidAreaType.TYPE_SYSTEM; - windowClass.getAvoidArea(type, (err, data) => { - if (err) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); - }); - ``` - - -## moveTo7+ - -moveTo\(x: number, y: number, callback: AsyncCallback\): void - -Moves this window. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

x

-

number

-

Yes

-

Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.

-

y

-

number

-

Yes

-

Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.moveTo(300, 300, (err, data)=>{ - if (err) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window moved. Data:' + JSON.stringify(data)); - - }); - ``` - - -## resetSize7+ - -resetSize\(width: number, height: number, callback: AsyncCallback\): void - -Changes the size of this window. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

width

-

number

-

Yes

-

New width of the window.

-

height

-

number

-

Yes

-

New height of the window.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.resetSize(500, 1000, (err, data) => { - if (err) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window size changed. Data:' + JSON.stringify(data)); - }); - ``` - - -## loadContent7+ - -loadContent\(path: string, callback: AsyncCallback\): void - -Loads content to the subwindow. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

path

-

string

-

Yes

-

Path of the page to which the content will be loaded.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.loadContent("pages/page2/page2", (err, data) => { - if (err) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data:' + JSON.stringify(data)); - }); - ``` - - -## hide7+ - -hide \(callback: AsyncCallback\): void - -Hides the subwindow. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.hide((err, data) => { - if (err) { - console.error('Failed to hide the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Subwindow hidden. Data:' + JSON.stringify(data)) - }) - ``` - - -## show7+ - -show\(callback: AsyncCallback\): void - -Shows the subwindow. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.show((err, data) => { - if (err) { - console.error('Failed to show the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the subwindow. Data: ' + JSON.stringify(data)) - }) - ``` - - -## isShowing7+ - -isShowing\(callback: AsyncCallback\): void - -Checks whether the subwindow is displayed. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to indicate whether the subwindow is displayed.

-
- -- Example - - ``` - windowClass.isShowing((err, data) => { - if (err) { - console.error('Failed to check whether the subwindow is showing. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the subwindow is showing. Cause:' + JSON.stringify(data)) - }) - ``` - - -## destroy7+ - -destroy\(callback: AsyncCallback\): void - -Destroys the subwindow. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.destroy((err, data) => { - if (err) { - console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the subwindow. Data:' + JSON.stringify(data)) - }) - ``` - - -## setOutsideTouchable7+ - -setOutsideTouchable\(touchable: boolean, callback: AsyncCallback\): void; - -Sets whether the area outside the subwindow is touchable. - -- Parameters - - - - - - - - - - - - - - - - - - - -

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.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- -- Example - - ``` - windowClass.setOutsideTouchable(true, (err, data) => { - if (err) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) - }) - ``` - - -## on\('keyboardHeightChange'\) - -on\(type: string, callback: AsyncCallback\): void - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is deprecated since API version 7. +find(id: string): Promise<Window> -Enables listening for keyboard height changes. +Finds a window based on the ID. This API uses a promise to return the result. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

string

-

Yes

-

Listening type. Set it to keyboardHeightChange, which indicates listening for keyboard height changes.

-

callback

-

AsyncCallback<number>

-

Yes

-

Callback used to return the keyboard height.

-
- -- Example - - ``` - var type= 'keyboardHeightChange'; - windowClass.on(type, (err, data) => { - if (err) { - console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); - }); - ``` - - -## off\('keyboardHeightChange'\) - -off\(type: string, callback?: AsyncCallback\): void - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is deprecated since API version 7. +**System capability**: SystemCapability.WindowManager.WindowManager.Core -Disables listening for keyboard height changes. +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------- | + | id | string | Yes | Window ID.| + +- Return value + + | Type | Description | + | -------------------------------- | ----------------------------------------------- | + | Promise<[Window](#window)> | Promise used to return the window found.| + +- Example + + ``` + var windowClass = null; + let promise = window.find("alertWindow"); + promise.then((data)=> { + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + }); + ``` -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

string

-

Yes

-

Listener type. Set it to keyboardHeightChange, which indicates a listener for keyboard height changes.

-

callback

-

AsyncCallback<number>

-

No

-

Callback used to return the keyboard height.

-
- -- Example - - ``` - var type= 'keyboardHeightChange'; - windowClass.off(type); - ``` - -### on('keyboardHeightChange'|'windowSizeChange'7+|'systemAvoidAreaChange'7+) - -on(type: string, callback: Callback<AvoidArea | Size | number>): void - -Enables listening. +## window.getTopWindow + +getTopWindow(callback: AsyncCallback<Window>): void + +Obtains the top window of the current application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core - Parameters - | Name | Type | Mandatory | Description | - | -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | - | type | string | Yes | Listening type.
- **keyboardHeightChange**: listening for keyboard height changes.
- **windowSizeChange'7+**: listening for window size changes.
- **systemAvoidAreaChange'7+**: listening for changes to the area where the window cannot be displayed. | - | callback | Callback<[AvoidArea](#section74393271254) \| [Size](#section695585431120) \| number> | Yes | Callback used to return the information. | + | Name | Type | Mandatory| Description | + | -------- | -------------------------------------- | ---- | -------------------------------------- | + | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| - Example ``` - var type = 'windowSizeChange'; + var windowClass = null; + window.getTopWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }); + ``` + +## window.getTopWindow + +getTopWindow(): Promise<Window> + +Obtains the top window of the current application. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | -------------------------------- | --------------------------------------------------------- | + | Promise<[Window](#window)> | Promise used to return the top window obtained.| + +- Example + + ``` + var windowClass = null; + let promise = window.getTopWindow(); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }) + ``` + +## window.getTopWindow8+ + +getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void + +Obtains the top window of the current application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | Yes | Current application context. | + | callback | AsyncCallback<[Window](#window)> | Yes | Callback used to return the top window obtained.| + +- Example + + ``` + var windowClass = null; + window.getTopWindow(this.context, (err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + }); + ``` + +## window.getTopWindow8+ + +getTopWindow(ctx: Context): Promise<Window> + +Obtains the top window of the current application. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------------------------------------------------------------ | ---- | -------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | Yes | Current application context.| + +- Return value + + | Type | Description | + | -------------------------------- | --------------------------------------------------------- | + | Promise<[Window](#window)> | Promise used to return the top window obtained.| + +- Example + + ``` + var windowClass = null; + let promise = window.getTopWindow(this.context); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + }) + ``` + +## on('systemBarTintChange')8+ + +on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void + +Enables listening for the properties changes of the status bar and navigation bar. + +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 | Listening type.
Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.| + | callback | Callback<[SystemBarTintState](#systembartintstate)> | Yes | Callback used to return the listened information. | + +- Example + + ``` + var type = 'systemBarTintChange'; 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 systemBarTint changes. Data: ' + JSON.stringify(data)); }); ``` -### off('keyboardHeightChange'|'windowSizeChange'7+|'systemAvoidAreaChange'7+) +## off('systemBarTintChange')8+ + +off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void -off(type: string, callback?: Callback<AvoidArea | Size | number>): void +Disables listening for the properties changes of the status bar and navigation bar. -Disables listening. +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 | Listening type.
- **'keyboardHeightChange'**: listening for keyboard height changes.
- **'windowSizeChange'7+**: listening for window size changes.
- **'systemAvoidAreaChange'7+**: listening for changes to the area where the window cannot be displayed. | - | callback | Callback<[AvoidArea](#section74393271254) \| [Size](#section695585431120) \| number> | No | Callback used to return the information. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | Yes | Listening type.
Set it to **systemBarTintChange**, which indicates listening for properties changes of the status bar and navigation bar.| + | callback | Callback<[SystemBarTintState](#systembartintstate)> | No | Callback used to return the listened information. | - Example ``` - var type = 'windowSizeChange'; + var type = 'systemBarTintChange'; windowClass.off(type); ``` + +## Window + +In the following API examples, you must use [getTopWindow()](#window-gettopwindow), [create()](#window-create), or [find()](#window-find) to obtain a **Window** instance and then call a method in this instance. + +### hide7+ + +hide (callback: AsyncCallback<void>): void + +Hides this window. 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<void> | Yes | Callback used to return the execution result.| + +- Example + + ``` + windowClass.hide((err, data) => { + if (err.code) { + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('window hidden. data: ' + JSON.stringify(data)) + }) + ``` + +### hide7+ + +hide(): Promise<void> + +Hides this window. 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<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.hide(); + promise.then((data)=> { + console.info('window hidden. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + }) + ``` + +### show7+ + +show(callback: AsyncCallback<void>): void + +Shows this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ---------- | + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| + +- Example + + ``` + windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) + }) + ``` + +### show7+ + +show(): Promise<void> + +Shows this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.show(); + promise.then((data)=> { + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + }) + ``` + +### destroy7+ + +destroy(callback: AsyncCallback<void>): void + +Destroys this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ---------- | + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| + +- Example + + ``` + windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) + }) + ``` + +### destroy7+ + +destroy(): Promise<void> + +Destroys this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.destroy(); + promise.then((data)=> { + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + }) + ``` + +### moveTo7+ + +moveTo(x: number, y: number, callback: AsyncCallback<void>): void + +Moves the position of this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | --------------------------------------- | + | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| + | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.moveTo(300, 300, (err, data)=>{ + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Window moved. Data: ' + JSON.stringify(data)) + + }); + ``` + +### moveTo7+ + +moveTo(x: number, y: number): Promise<void> + +Moves the position of this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | --------------------------------------- | + | x | number | Yes | Distance that the window moves along the x-axis. A positive value indicates that the window moves to the right.| + | y | number | Yes | Distance that the window moves along the y-axis. A positive value indicates that the window moves downwards.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.moveTo(300, 300); + promise.then((data)=> { + console.info('Window moved. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); + }) + ``` + +### resetSize7+ + +resetSize(width: number, height: number, callback: AsyncCallback<void>): void + +Changes the size of this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ---------------- | + | width | number | Yes | New width of the window.| + | height | number | Yes | New height of the window.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Window size changed. Data: ' + JSON.stringify(data)) + }); + ``` + +### resetSize7+ + +resetSize(width: number, height: number): Promise<void> + +Changes the size of this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------- | + | width | number | Yes | New width of the window.| + | height | number | Yes | New height of the window.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.resetSize(500, 1000); + promise.then((data)=> { + console.info('Window size changed. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setWindowType7+ + +setWindowType(type: WindowType, callback: AsyncCallback<void>): void + +Sets the type of this window. 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 | + | -------- | ------------------------- | ---- | ---------- | + | type | [WindowType](#windowtype) | Yes | Window type.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result.| + +- Example + + ``` + var type = window.TYPE_APP; + windowClass.setWindowType(type, (err, data) => { + if (err.code) { + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) + }); + ``` + +### setWindowType7+ + +setWindowType(type: WindowType): Promise<void> + +Sets the type of this window. 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 | + | ------ | ------------------------- | ---- | ---------- | + | type | [WindowType](#windowtype) | Yes | Window type.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var type = window.TYPE_APP; + let promise = windowClass.setWindowType(type); + promise.then((data)=> { + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + }); + ``` + +### getProperties + +getProperties(callback: AsyncCallback<WindowProperties>): void + +Obtains the properties of this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ---------------------------------------------------------- | ---- | ------------------ | + | callback | AsyncCallback<[WindowProperties](#windowproperties)> | Yes | Callback used to return the window properties.| + +- Example + + ``` + windowClass.getProperties((err, data) => { + if (err.code) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); + }); + ``` + +### getProperties + +getProperties(): Promise<WindowProperties> + +Obtains the properties of this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ---------------------------------------------------- | ------------------------------------- | + | Promise<[WindowProperties](#windowproperties)> | Promise used to return the window properties.| + +- Example + + ``` + let promise = windowClass.getProperties(); + promise.then((data)=> { + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); + }); + ``` + +### getAvoidArea7+ + +getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): 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. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + | callback | AsyncCallback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the area. | + +- Example + + ``` + var type = window.AvoidAreaType.TYPE_SYSTEM; + windowClass.getAvoidArea(type, (err, data) => { + if (err.code) { + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); + }); + ``` + +### getAvoidArea7+ + +getAvoidArea(type: AvoidAreaType): Promise<AvoidArea> + +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. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + +- Return value + + | Type | Description | + | -------------------------------------- | --------------------------------------------- | + | Promise<[AvoidArea](#avoidarea)> | Promise used to return the area.| + +- Example + + ``` + let promise = windowClass.getAvoidArea(); + promise.then((data)=> { + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); + }); + ``` + +### setFullScreen + +setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void + +Sets whether to enable the full-screen mode for this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------ | ------------------------- | ---- | ---------------------------------------------- | + | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var isFullScreen = true; + windowClass.setFullScreen(isFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) + }); + ``` + +### setFullScreen + +setFullScreen(isFullScreen: boolean): Promise<void> + +Sets whether to enable the full-screen mode for this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------ | ------- | ---- | ---------------------------------------------- | + | isFullScreen | boolean | Yes | Whether to enable the full-screen mode, in which the status bar and navigation bar are hidden.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var isFullScreen = true; + let promise = windowClass.setFullScreen(isFullScreen); + promise.then((data)=> { + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setLayoutFullScreen7+ + +setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void + +Sets whether the window layout is in full-screen mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | + | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var isLayoutFullScreen= true; + windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) + }); + ``` + +### setLayoutFullScreen7+ + +setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> + +Sets whether the window layout is in full-screen mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------------ | ------- | ---- | ------------------------------------------------------------ | + | isLayoutFullScreen | boolean | Yes | Whether the window layout is in full-screen mode, in which the status bar and navigation bar are displayed.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var isLayoutFullScreen = true; + let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); + promise.then((data)=> { + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + }); + ``` + +### setSystemBarEnable7+ + +setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void + +Sets whether to display the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var names = ["status", "navigation"]; + windowClass.setSystemBarEnable(names, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) + }); + ``` + +### setSystemBarEnable7+ + +setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> + +Sets whether to display the status bar and navigation bar in this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var names = ["status", "navigation"]; + let promise = windowClass.setSystemBarEnable(names); + promise.then((data)=> { + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + }); + ``` + +### setSystemBarProperties + +setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +Sets the properties of the status bar and navigation bar in this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------------- | ------------------------------------------- | ---- | -------------------- | + | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + 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' + }; + windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) + }); + ``` + +### setSystemBarProperties + +setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> + +Sets the properties of the status bar and navigation bar in this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------------- | ------------------------------------------- | ---- | -------------------- | + | SystemBarProperties | [SystemBarProperties](#systembarproperties) | Yes | Properties of the status bar and navigation bar.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + 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)); + }); + ``` + +### loadContent7+ + +loadContent(path: string, callback: AsyncCallback<void>): void + +Loads content 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 to which the content will be loaded.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.loadContent("pages/page2/page2", (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)) + }); + ``` + +### loadContent7+ + +loadContent(path: string): Promise<void> + +Loads content to this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | -------------------- | + | path | string | Yes | Path of the page to which the content will be loaded.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.loadContent("pages/page2/page2"); + promise.then((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)); + }); + ``` + +### isShowing7+ + +isShowing(callback: AsyncCallback<boolean>): void + +Checks whether this window is displayed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ---------------------------- | ---- | -------------------------------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the window is displayed.| + +- Example + + ``` + windowClass.isShowing((err, data) => { + if (err.code) { + console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) + }); + ``` + +### isShowing7+ + +isShowing(): Promise<boolean> + +Checks whether this window is displayed. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ---------------------- | ----------------------------------------------------- | + | Promise<boolean> | Promise used to return whether the window is displayed.| + +- Example + + ``` + let promise = windowClass.isShowing(); + promise.then((data)=> { + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); + }); + ``` + +### on('windowSizeChange')7+ + +on(type: 'windowSizeChange', callback: Callback<Size>): void + +Enables listening for window size changes. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | + | type | string | Yes | Listening type.
Set it to **windowSizeChange**, which indicates listening for window size changes.| + | callback | Callback<[Size](#size)> | Yes | Callback used to return the listened information. | + +- Example + + ``` + var type = 'windowSizeChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('windowSizeChange')7+ + +off(type: 'windowSizeChange', callback?: Callback<Size >): void + +Disables listening for window size changes. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | + | type | string | Yes | Listening type.
Set it to **windowSizeChange7+**, which indicates listening for window size changes.| + | callback | Callback<[Size](#size)> | No | Callback used to return the listened information. | + +- Example + + ``` + var type = 'windowSizeChange'; + windowClass.off(type); + ``` + +### on('systemAvoidAreaChange')7+ + +on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): 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 | Listening type.
Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.| + | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the listened information. | + +- Example + + ``` + var type = 'systemAvoidAreaChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('systemAvoidAreaChange')7+ + +off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): 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 | Listening type.
Set it to **systemAvoidAreaChange**, which indicates listening for changes to the area where the window cannot be displayed.| + | callback | Callback<[AvoidArea](#avoidarea)> | No | Callback used to return the listened information. | + +- Example + + ``` + var type = 'systemAvoidAreaChange'; + windowClass.off(type); + ``` + +### on('keyboardHeightChange')7+ + +on(type: 'keyboardHeightChange', callback: Callback<number>): void + +Enables listening for keyboard height changes. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | Yes | Listening type.
Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.| + | callback | Callback<[AvoidArea](#avoidarea)> | Yes | Callback used to return the listened information. | + +- Example + + ``` + var type = 'keyboardHeightChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('keyboardHeightChange')7+ + +off(type: 'keyboardHeightChange', callback?: Callback<number>): void + +Disables listening for keyboard height changes. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ---------------------- | ---- | ------------------------------------------------------------ | + | type | string | Yes | Listening type.
Set it to **keyboardHeightChange**, which indicates listening for keyboard height changes.| + | callback | Callback<number> | No | Callback used to return the listened information. | + +- Example + + ``` + var type = 'keyboardHeightChange'; + windowClass.off(type); + ``` + +### isSupportWideGamut8+ + +isSupportWideGamut(callback: AsyncCallback<boolean>): void + +Checks whether this window supports the wide color gamut mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ---------------------------- | ---- | -------------------------------- | + | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the wide color gamut mode is supported.| + +- Example + + ``` + windowClass.isSupportWideGamut((err, data) => { + if (err.code) { + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)) + }) + ``` + +### isSupportWideGamut8+ + +isSupportWideGamut(): Promise<boolean> + +Checks whether this window supports the wide color gamut mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ---------------------- | ------------------------------------------------------------ | + | Promise<boolean> | Promise used to return whether the wide color gamut mode is supported.| + +- Example + + ``` + let promise = windowClass.isSupportWideGamut(); + promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setColorSpace8+ + +setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void + +Sets this window to the wide or default color gamut mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ---------- | ------------------------- | ---- | ------------ | + | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { + if (err.code) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) + }) + ``` + +### setColorSpace8+ + +setColorSpace(colorSpace:ColorSpace): Promise<void> + +Sets this window to the wide or default color gamut mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ---------- | ------------------------- | ---- | ------------ | + | colorSpace | [ColorSpace](#colorspace) | Yes | Color gamut mode.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); + promise.then((data)=> { + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); + }); + ``` + +### getColorSpace8+ + +getColorSpace(callback: AsyncCallback<ColorSpace>): void + +Obtains the color gamut mode of this window. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ---------------------------------------------- | ---- | -------------------------- | + | callback | AsyncCallback<[ColorSpace](#colorspace)> | Yes | Callback used to return the color gamut mode obtained.| + +- Example + + ``` + windowClass.getColorSpace((err, data) => { + if (err.code) { + console.error('Failed to get window color space. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) + }) + ``` + +### getColorSpace8+ + +getColorSpace(): Promise<ColorSpace> + +Obtains the color gamut mode of this window. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type | Description | + | ---------------------------------------- | ----------------------------------------- | + | Promise<[ColorSpace](#colorspace)> | Promise used to return the color gamut mode obtained.| + +- Example + + ``` + let promise = windowClass.getColorSpace(); + promise.then((data)=> { + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setBackgroundColor + +setBackgroundColor(color: string, callback: AsyncCallback<void>): void + +Sets the background color for this window. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ------------------------------------------------------------ | + | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var color = '#00ff33'; + windowClass.setBackgroundColor(color, (err, data) => { + if (err.code) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBackgroundColor + +setBackgroundColor(color: string): Promise<void> + +Sets the background color for this window. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------------------------------ | + | color | string | Yes | Background color to set. The color is a hexadecimal value, for example, #00FF00 or #FF00FF00.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var color = '#00ff33'; + let promise = windowClass.setBackgroundColor(color); + promise.then((data)=> { + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number, callback: AsyncCallback<void>): void + +Sets the screen brightness for this window. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ---------- | ------------------------- | ---- | ------------------------------------ | + | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var brightness = 1; + windowClass.setBrightness(brightness, (err, data) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number): Promise<void> + +Sets the screen brightness for this window. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ---------- | ------ | ---- | ------------------------------------ | + | brightness | number | Yes | Brightness to set, which ranges from 0 to 1. The value **1** indicates the brightest.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var brightness = 1; + let promise = windowClass.setBrightness(brightness); + promise.then((data)=> { + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void + +Sets the dimness of the window that is not on top. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.setDimBehind(0.5, (err, data) => { + if (err.code) { + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number): Promise<void> + +Sets the dimness of the window that is not on top. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.setDimBehind(0.5); + promise.then((data)=> { + console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void + +Sets whether this window can gain focus. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ----------- | ------------------------- | ---- | ---------------------------- | + | isFocusable | boolean | Yes | Whether the window can gain focus.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var isFocusable= true; + windowClass.setFocusable(isFocusable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean): Promise<void> + +Sets whether this window can gain focus. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ----------- | ------- | ---- | ---------------------------- | + | isFocusable | boolean | Yes | Whether the window can gain focus.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var isFocusable= true; + let promise = windowClass.setFocusable(isFocusable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void + +Sets whether to keep the screen always on. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | -------------- | ------------------------- | ---- | ------------------------ | + | isKeepScreenOn | boolean | Yes | Whether to keep the screen always on.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + 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<void> + +Sets whether to keep the screen always on. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**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<void> | Promise used to return the execution result.| + +- Example + + ``` + 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)); + }); + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void + +Sets whether the area outside the subwindow is touchable. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + windowClass.setOutsideTouchable(true, (err, data) => { + if (err.code) { + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }) + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean): Promise<void> + +Sets whether the area outside the subwindow is touchable. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | 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.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + let promise = windowClass.setOutsideTouchable(true); + promise.then((data)=> { + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void + +Sets whether this window is in privacy mode. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------- | ------------------------- | ---- | -------------------- | + | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var isPrivacyMode = true; + windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); + + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean): Promise<void> + +Sets whether this window is in privacy mode. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ------------- | ------- | ---- | -------------------- | + | isPrivacyMode | boolean | Yes | Whether the window is in privacy mode.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var isPrivacyMode = true; + let promise = windowClass.setPrivacyMode(isPrivacyMode); + promise.then((data)=> { + console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void + +Sets whether this window is touchable. This API uses an asynchronous callback to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ----------- | ------------------------- | ---- | -------------------- | + | isTouchable | boolean | Yes | Whether the window is touchable.| + | callback | AsyncCallback<void> | Yes | Callback used to return the execution result. | + +- Example + + ``` + var isTouchable = true; + windowClass.setTouchable(isTouchable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); + + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean): Promise<void> + +Sets whether this window is touchable. This API uses a promise to return the result. + +This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +- Parameters + + | Name | Type | Mandatory| Description | + | ----------- | ------- | ---- | -------------------- | + | isTouchable | boolean | Yes | Whether the window is touchable.| + +- Return value + + | Type | Description | + | ------------------- | ----------------------------------------------- | + | Promise<void> | Promise used to return the execution result.| + +- Example + + ``` + var isTouchable = true; + let promise = windowClass.setTouchable(isTouchable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +###