diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md
index 9a5501a92c31ce08f5554be9b57121c016c41f4b..fb1bc18c0aa21d0b0d34d84ca9c598c779314b7e 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-window.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-window.md
@@ -1,12 +1,15 @@
# 窗口
-窗口提供管理窗口的一些基础能力,包括对窗口的创建、销毁,以及对窗口的属性设置等各项功能。
+窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。
+
+该模块提供以下窗口相关的常用功能:
+
+- [Window](#window):当前窗口实例,窗口管理器管理的基本单元。
+- [WindowStage](#windowstage9):窗口管理器。管理各个基本窗口单元。
> **说明:**
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
->
-> API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
## 导入模块
@@ -16,54 +19,55 @@ import window from '@ohos.window';
## WindowType7+
-窗口类型。
+窗口类型枚举。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-| 名称 | 默认值 | 说明 |
+| 名称 | 值 | 说明 |
| ----------------- | ------ | ------------------ |
-| TYPE_APP | 0 | 表示应用子窗口。 |
+| TYPE_APP | 0 | 表示应用子窗口。 |
| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。 |
+
## AvoidAreaType7+
-窗口内容需要规避区域的类型。
+窗口内容需要规避区域的类型枚举。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-| 名称 | 默认值 | 说明 |
-| ----------- | ------ | ------------------ |
-| TYPE_SYSTEM | 0 | 表示系统默认区域。 |
-| TYPE_CUTOUT | 1 | 表示刘海屏区域。 |
+| 名称 | 值 | 说明 |
+| ----------- | ---- | ------------------ |
+| TYPE_SYSTEM | 0 | 表示系统默认区域。 |
+| TYPE_CUTOUT | 1 | 表示刘海屏区域。 |
## WindowMode7+
-窗口模式。
+窗口模式枚举。
此接口为系统接口,三方应用不支持调用。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-| 名称 | 默认值 | 说明 |
-| ---------- | ------ | ----------------------------- |
-| UNDEFINED | 1 | 表示APP未定义窗口模式。 |
-| FULLSCREEN | 2 | 表示APP全屏模式。 |
-| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 |
-| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 |
-| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 |
+| 名称 | 值 | 说明 |
+| ---------- | ---- | ----------------------------- |
+| UNDEFINED | 1 | 表示APP未定义窗口模式。 |
+| FULLSCREEN | 2 | 表示APP全屏模式。 |
+| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 |
+| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 |
+| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 |
## SystemBarProperties
-状态栏导航栏的属性。
+状态栏、导航栏的属性。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
-| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 |
+| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 |
| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 |
-| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 |
+| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。 |
| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 |
@@ -73,14 +77,14 @@ import window from '@ohos.window';
此接口为系统接口,三方应用不支持调用。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 |
| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。 |
-| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如"\#00FF00"或"\#FF00FF00"。 |
+| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
| contentColor | string | 是 | 是 | 系统栏文字颜色。 |
## SystemBarTintState8+
@@ -89,18 +93,18 @@ import window from '@ohos.window';
此接口为系统接口,三方应用不支持调用。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-| 名称 | 参数类型 | 可读 | 可写 | 说明 |
-| ---------- | --------------------------------------------------- | ---- | ---- | -------------------------- |
-| displayId | number | 是 | 否 | 当前物理屏幕id。 |
-| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是 | 是 | 当前改变所有的系统栏信息。 |
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
+| displayId | number | 是 | 否 | 当前物理屏幕id。 |
+| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是 | 是 | 当前已改变的所有系统栏信息。 |
## Rect7+
窗口矩形区域。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------ | -------- | ---- | ---- | ------------------ |
@@ -113,7 +117,7 @@ import window from '@ohos.window';
窗口内容规避区域。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ---------- | ------------- | ---- | ---- | ------------------ |
@@ -126,7 +130,7 @@ import window from '@ohos.window';
窗口大小。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------ | -------- | ---- | ---- | ---------- |
@@ -137,7 +141,7 @@ import window from '@ohos.window';
窗口属性。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
@@ -158,7 +162,7 @@ import window from '@ohos.window';
色域模式。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 默认值 | 说明 |
| ---------- | ------ | -------------- |
@@ -171,32 +175,28 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi
创建子窗口,使用callback异步回调。
-从API version 8开始,此接口废弃,推荐使用[window.create8+](#windowcreate8)接口。
-
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------- | ---- | -------------------------- |
-| id | string | 是 | 窗口id。 |
-| type | [WindowType](#windowtype) | 是 | 窗口类型。 |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回创建的子窗口对象。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | ------------------------------------ |
+| id | string | 是 | 窗口id。 |
+| type | [WindowType](#windowtype) | 是 | 窗口类型。 |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 |
**示例:**
- ```js
- 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);
- });
- ```
+```js
+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.create7+
@@ -204,8 +204,6 @@ create(id: string, type: WindowType): Promise<Window>
创建子窗口,使用Promise异步回调。
-从API version 8开始,此接口废弃,推荐使用[window.create8+](#windowcreate8)接口。
-
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
@@ -217,22 +215,22 @@ create(id: string, type: WindowType): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | ------------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前创建的子窗口对象。 |
+| 类型 | 说明 |
+| -------------------------------- | --------------------------------------- |
+| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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.create8+
@@ -251,22 +249,22 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi
| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 |
| id | string | 是 | 窗口id。 |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 |
**示例:**
- ```js
- 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;
- console.info('Window created. Data: ' + JSON.stringify(data))
- windowClass.resetSize(500, 1000);
- });
- ```
+```js
+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;
+ console.info('Window created. Data: ' + JSON.stringify(data));
+ windowClass.resetSize(500, 1000);
+});
+```
## window.create8+
@@ -288,22 +286,22 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | ----------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前创建的窗口对象。 |
+| 类型 | 说明 |
+| -------------------------------- | --------------------------------------- |
+| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -315,24 +313,24 @@ find(id: string, callback: AsyncCallback<Window>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------- | ---- | ---------------------------- |
-| id | string | 是 | 窗口id。 |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前查找的窗口对象。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | ------------------------------------ |
+| id | string | 是 | 窗口id。 |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前查找到的窗口对象。 |
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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+
@@ -350,22 +348,22 @@ find(id: string): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | ----------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前查找的窗口对象。 |
+| 类型 | 说明 |
+| -------------------------------- | ------------------------------------- |
+| Promise<[Window](#window)> | Promise对象。返回当前查找的窗口对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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));
+});
+```
## window.getTopWindow
@@ -373,29 +371,27 @@ getTopWindow(callback: AsyncCallback<Window>): void
获取当前应用内最后显示的窗口,使用callback异步回调。
-从API version 8开始,此接口废弃,推荐使用[window.getTopWindow8+](#windowgettopwindow8)接口。
-
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------- | ---- | -------------------------------------- |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | -------------------------------------------- |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -403,28 +399,26 @@ getTopWindow(): Promise<Window>
获取当前应用内最后显示的窗口,使用Promise异步回调。
-从API version 8开始,此接口废弃,推荐使用[window.getTopWindow8+](#windowgettopwindow8)接口。
-
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | --------------------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前应用内最后显示的窗口对象。 |
+| 类型 | 说明 |
+| -------------------------------- | ----------------------------------------------- |
+| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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+
@@ -439,21 +433,21 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -471,28 +465,28 @@ getTopWindow(ctx: Context): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | --------------------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前应用内最后显示的窗口对象。 |
+| 类型 | 说明 |
+| -------------------------------- | ----------------------------------------------- |
+| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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
-注册状态栏、导航栏的监听函数。
+开启状态栏、导航栏属性变化的监听。
此接口为系统接口,三方应用不支持调用。
@@ -503,22 +497,21 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
-| callback | Callback<[SystemBarTintState](#systembartintstate)> | 是 | 回调返回监听到的信息。 |
+| callback | Callback<[SystemBarTintState](#systembartintstate)> | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:**
- ```js
- var type = 'systemBarTintChange';
- windowClass.on(type, (data) => {
- console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
- });
- ```
+```js
+window.on('systemBarTintChange', (data) => {
+ console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
+});
+```
## off('systemBarTintChange')8+
off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void
-关闭监听。
+关闭状态栏、导航栏属性变化的监听。
此接口为系统接口,三方应用不支持调用。
@@ -529,17 +522,18 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
-| callback | Callback<[SystemBarTintState](#systembartintstate)> | 否 | 回调返回监听到的信息。 |
+| callback | Callback<[SystemBarTintState](#systembartintstate)> | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:**
- ```js
- var type = 'systemBarTintChange';
- windowClass.off(type);
- ```
+```js
+window.off('systemBarTintChange');
+```
## Window
+当前窗口实例,窗口管理器管理的基本单元。
+
下列API示例中都需先使用[getTopWindow()](#windowgettopwindow)、[create()](#windowcreate7)、[find()](#windowfind7)中的任一方法获取到Window实例,再通过此实例调用对应方法。
### hide7+
@@ -560,15 +554,15 @@ hide (callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- })
- ```
+```js
+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+
@@ -582,20 +576,20 @@ hide(): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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+
@@ -613,15 +607,15 @@ show(callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- })
- ```
+```js
+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+
@@ -633,20 +627,20 @@ show(): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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+
@@ -664,15 +658,15 @@ destroy(callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- })
- ```
+```js
+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+
@@ -684,20 +678,20 @@ destroy(): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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+
@@ -717,16 +711,16 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
-
- });
- ```
+```js
+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+
@@ -745,20 +739,20 @@ moveTo(x: number, y: number): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- })
- ```
+```js
+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+
@@ -778,15 +772,15 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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+
@@ -805,20 +799,20 @@ resetSize(width: number, height: number): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -839,16 +833,16 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- });
- ```
+```js
+var type = window.WindowType.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+
@@ -868,21 +862,21 @@ setWindowType(type: WindowType): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+var type = window.WindowType.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
@@ -894,21 +888,21 @@ getProperties(callback: AsyncCallback<WindowProperties>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------------------- | ---- | ------------------ |
-| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调返回窗口属性。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------------------- | ---- | ---------------------------- |
+| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调函数。返回当前窗口属性。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -920,20 +914,20 @@ getProperties(): Promise<WindowProperties>
**返回值:**
-| 类型 | 说明 |
-| ---------------------------------------------------- | ------------------------------------- |
-| Promise<[WindowProperties](#windowproperties)> | 以Promise形式返回结果,返回窗口属性。 |
+| 类型 | 说明 |
+| ---------------------------------------------------- | ------------------------------- |
+| Promise<[WindowProperties](#windowproperties)> | Promise对象。返回当前窗口属性。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -948,20 +942,20 @@ getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。 |
-| callback | AsyncCallback<[AvoidArea](#avoidarea)> | 是 | 回调返回窗口内容规避区域。 |
+| callback | AsyncCallback<[AvoidArea](#avoidarea)> | 是 | 回调函数。返回窗口内容规避区域。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -979,20 +973,20 @@ getAvoidArea(type: AvoidAreaType): Promise<AvoidArea>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------------- | --------------------------------------------- |
-| Promise<[AvoidArea](#avoidarea)> | 以Promise形式返回结果,返回窗口内容规避区域。 |
+| 类型 | 说明 |
+| -------------------------------------- | ----------------------------------- |
+| Promise<[AvoidArea](#avoidarea)> | Promise对象。返回窗口内容规避区域。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1011,16 +1005,16 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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
@@ -1038,21 +1032,21 @@ setFullScreen(isFullScreen: boolean): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -1071,16 +1065,16 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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+
@@ -1098,21 +1092,21 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -1126,21 +1120,21 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
-| names | Array | 是 | 设置状态栏和导航栏是否显示。例如,需全部显示,该参数设置为["status", "navigation"], 不设置,则默认不显示。 |
+| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为["status", "navigation"];不设置,则默认不显示。 |
| callback | AsyncCallback<void> | 是 | 回调函数。 |
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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+
@@ -1154,25 +1148,25 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----- | ---- | ------------------------------------------------------------ |
-| names | Array | 是 | 设置状态栏和导航栏是否显示。例如,需全部显示,该参数设置为["status", "navigation"], 不设置,则默认不显示。 |
+| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为["status", "navigation"];不设置,则默认不显示。 |
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1184,32 +1178,32 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------------- | ------------------------------------------- | ---- | -------------------- |
-| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏状态栏的属性。 |
-| callback | AsyncCallback<void> | 是 | 回调函数。 |
-
-**示例:**
-
- ```js
- var SystemBarProperties={
- statusBarColor: '#ff00ff',
- navigationBarColor: '#00ff00',
- //以下两个属性从API Version7开始支持
- isStatusBarLightIcon: true,
- isNavigationBarLightIcon:false,
- //以下两个属性从API Version8开始支持
- 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))
- });
- ```
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------------- | ------------------------------------------- | ---- | ---------------------- |
+| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。 |
+
+**示例:**
+
+```js
+var SystemBarProperties={
+ statusBarColor: '#ff00ff',
+ navigationBarColor: '#00ff00',
+ //以下两个属性从API Version7开始支持
+ isStatusBarLightIcon: true,
+ isNavigationBarLightIcon:false,
+ //以下两个属性从API Version8开始支持
+ 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
@@ -1221,42 +1215,42 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------------------- | ------------------------------------------- | ---- | -------------------- |
-| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏状态栏的属性。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------------------- | ------------------------------------------- | ---- | ---------------------- |
+| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 |
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
-
-**示例:**
-
- ```js
- var SystemBarProperties={
- statusBarColor: '#ff00ff',
- navigationBarColor: '#00ff00',
- //以下两个属性从API Version7开始支持
- isStatusBarLightIcon: true,
- isNavigationBarLightIcon:false,
- //以下两个属性从API Version8开始支持
- 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));
- });
- ```
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
+
+**示例:**
+
+```js
+var SystemBarProperties={
+ statusBarColor: '#ff00ff',
+ navigationBarColor: '#00ff00',
+ //以下两个属性从API Version7开始支持
+ isStatusBarLightIcon: true,
+ isNavigationBarLightIcon:false,
+ //以下两个属性从API Version8开始支持
+ 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
-当前窗口加载具体页面内容,使用callback异步回调。
+为当前窗口加载具体页面内容,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
@@ -1269,21 +1263,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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>
-当前窗口加载具体页面内容,使用Promise异步回调。
+为当前窗口加载具体页面内容,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
@@ -1295,21 +1289,20 @@ loadContent(path: string): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
-
+```js
+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
@@ -1320,21 +1313,21 @@ isShowing(callback: AsyncCallback<boolean>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | -------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调函数返回是否显示子窗口结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 |
**示例:**
- ```js
- 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))
- });
- ```
+```js
+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+
@@ -1346,50 +1339,49 @@ isShowing(): Promise<boolean>
**返回值:**
-| 类型 | 说明 |
-| ---------------------- | ----------------------------------------------------- |
-| Promise<boolean> | 以Promise形式返回结果,返回当前窗口是否已显示的结果。 |
+| 类型 | 说明 |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
-开启监听。
+开启窗口尺寸变化的监听。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
-| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
-| callback | Callback<[Size](#size)> | 是 | 回调返回监听到的信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------ | ---- | -------------------------------------------------------- |
+| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
+| callback | Callback<[Size](#size7)> | 是 | 回调函数。返回当前的窗口尺寸。 |
**示例:**
- ```js
- var type = 'windowSizeChange';
- windowClass.on(type, (data) => {
- console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
- });
- ```
+```js
+windowClass.on('windowSizeChange', (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
-关闭监听。
+关闭窗口尺寸变化的监听。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
@@ -1398,20 +1390,19 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
-| callback | Callback<[Size](#size)> | 否 | 回调返回监听到的信息。 |
+| callback | Callback<[Size](#size)> | 否 | 回调函数。返回当前的窗口尺寸。 |
**示例:**
- ```js
- var type = 'windowSizeChange';
- windowClass.off(type);
- ```
+```js
+windowClass.off('windowSizeChange');
+```
### on('systemAvoidAreaChange')7+
on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void
-开启监听。
+开启系统窗口规避区变化的监听。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
@@ -1420,22 +1411,21 @@ on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
-| callback | Callback<[AvoidArea](#avoidarea)> | 是 | 回调返回监听到的信息。 |
+| callback | Callback<[AvoidArea](#avoidarea)> | 是 | 回调函数。返回当前的窗口规避区。 |
**示例:**
- ```js
- var type = 'systemAvoidAreaChange';
- windowClass.on(type, (data) => {
- console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data));
- });
- ```
+```js
+windowClass.on('systemAvoidAreaChange', (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
-关闭监听。
+关闭系统窗口规避区变化的监听。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
@@ -1444,14 +1434,13 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
-| callback | Callback<[AvoidArea](#avoidarea)> | 否 | 回调返回监听到的信息。 |
+| callback | Callback<[AvoidArea](#avoidarea)> | 否 | 回调函数。返回当前的窗口规避区。 |
**示例:**
- ```js
- var type = 'systemAvoidAreaChange';
- windowClass.off(type);
- ```
+```js
+windowClass.off('systemAvoidAreaChange');
+```
### on('keyboardHeightChange')7+
@@ -1463,19 +1452,18 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ------------------ | ---- | ------------------------------------------------------------ |
-| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
-| callback | Callbacknumber> | 是 | 回调返回监听到的信息。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------- | ---- | ------------------------------------------------------------ |
+| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
+| callback | Callback {
- console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
- });
- ```
+```js
+windowClass.on('keyboardHeightChange', (data) => {
+ console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
+});
+```
### off('keyboardHeightChange')7+
@@ -1490,14 +1478,13 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
-| callback | Callback<number> | 否 | 回调返回监听到的信息。 |
+| callback | Callback<number> | 否 | 回调函数。返回当前的键盘高度。 |
**示例:**
- ```js
- var type = 'keyboardHeightChange';
- windowClass.off(type);
- ```
+```js
+windowClass.off('keyboardHeightChange');
+```
### isSupportWideGamut8+
@@ -1509,21 +1496,21 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------- | ---- | -------------------------------- |
-| callback | AsyncCallback<boolean> | 是 | 回调函数返回是否支持广色域模式。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:**
- ```js
- 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))
- })
- ```
+```js
+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+
@@ -1537,18 +1524,18 @@ isSupportWideGamut(): Promise<boolean>
| 类型 | 说明 |
| ---------------------- | ------------------------------------------------------------ |
-| Promise<boolean> | 以Promise形式返回结果,返回当前窗口是否支持广色域模式的结果。 |
+| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -1567,15 +1554,15 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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))
- })
- ```
+```js
+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+
@@ -1587,26 +1574,26 @@ setColorSpace(colorSpace:ColorSpace): Promise<void>
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ---------- | ------------------------- | ---- | ------------ |
-| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 |
+| 参数名 | 类型 | 必填 | 说明 |
+| ---------- | ------------------------- | ---- | -------------- |
+| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 |
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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 colorspace. Cause: ' + JSON.stringify(err));
- });
- ```
+```js
+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 colorspace. Cause: ' + JSON.stringify(err));
+});
+```
### getColorSpace8+
@@ -1618,21 +1605,21 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | ---------------------------------------------- | ---- | -------------------------- |
-| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数返回当前色域模式。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- |
+| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数。当获取成功,err为undefined,data为当前色域模式。 |
**示例:**
- ```js
- windowClass.getColorSpace((err, data) => {
- if (err.code) {
- console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data))
- })
- ```
+```js
+windowClass.getColorSpace((err, data) => {
+ if (err.code) {
+ console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data));
+})
+```
### getColorSpace8+
@@ -1644,20 +1631,20 @@ getColorSpace(): Promise<ColorSpace>
**返回值:**
-| 类型 | 说明 |
-| ---------------------------------------- | ----------------------------------------- |
-| Promise<[ColorSpace](#colorspace)> | 以Promise形式返回结果,返回当前色域模式。 |
+| 类型 | 说明 |
+| ---------------------------------------- | ------------------------------- |
+| Promise<[ColorSpace](#colorspace)> | Promise对象。返回当前色域模式。 |
**示例:**
- ```js
- 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 get window colorspace. Cause: ' + JSON.stringify(err));
- });
- ```
+```js
+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 get window colorspace. Cause: ' + JSON.stringify(err));
+});
+```
### setBackgroundColor
@@ -1671,21 +1658,21 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
-| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如"#00FF00"或"#FF00FF00"。 |
+| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
| callback | AsyncCallback<void> | 是 | 回调函数。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1703,21 +1690,21 @@ setBackgroundColor(color: string): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1736,16 +1723,16 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1763,27 +1750,27 @@ setBrightness(brightness: number): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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));
+});
+```
### setDimBehind(deprecated)
setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
-窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback方式作为异步方法。
+窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。
> **说明:** 从API version 9开始废弃。
>
@@ -1793,28 +1780,28 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------------- | ------------------------- | ---- | -------------------------------------------------- |
- | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
- | callback | AsyncCallback<void> | 是 | 回调函数。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------------- | ------------------------- | ---- | -------------------------------------------------- |
+| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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));
+});
+```
### setDimBehind(deprecated)
setDimBehind(dimBehindValue: number): Promise<void>
-窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise方式作为异步方法。
+窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。
> **说明:** 从API version 9开始废弃。
>
@@ -1824,26 +1811,26 @@ setDimBehind(dimBehindValue: number): Promise<void>
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------------- | ------ | ---- | -------------------------------------------------- |
- | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------------- | ------ | ---- | -------------------------------------------------- |
+| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
**返回值:**
- | 类型 | 说明 |
- | ------------------- | ----------------------------------------------- |
- | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -1862,16 +1849,16 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -1889,21 +1876,21 @@ setFocusable(isFocusable: boolean): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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
@@ -1922,53 +1909,54 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v
**示例:**
- ```js
- var isKeepScreenOn = true;
- windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
- if (err.code) {
- console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
- });
- ```
-
-### setOutsideTouchable(deprecated)
+```js
+var isKeepScreenOn = true;
+windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
+ if (err.code) {
+ console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
+});
+```
-setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void
+### setKeepScreenOn
-设置是否允许可点击子窗口以外的区域,使用callback方式作为异步方法。
+setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>
-> **说明:** 从API version 9开始废弃。
->
-> 从 API version 7开始支持。
+设置屏幕是否为常亮状态,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-**参数:**
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------------- | ------- | ---- | ------------------------ |
+| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 |
- | 参数名 | 类型 | 必填 | 说明 |
- | --------- | ------------------------- | ---- | ---------------- |
- | touchable | boolean | 是 | 设置是否可点击。 |
- | callback | AsyncCallback<void> | 是 | 回调函数。 |
+**返回值:**
+
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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))
- })
- ```
+```js
+var isKeepScreenOn = true;
+let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
+promise.then((data) => {
+ console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
+}).catch((err)=>{
+ console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
+});
+```
### setOutsideTouchable(deprecated)
-setOutsideTouchable(touchable: boolean): Promise<void>
+setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void
-设置是否允许可点击子窗口以外的区域,使用Promise方式作为异步方法。
+设置是否允许可点击子窗口之外的区域,使用callback异步回调。
> **说明:** 从API version 9开始废弃。
>
@@ -1978,58 +1966,57 @@ setOutsideTouchable(touchable: boolean): Promise<void>
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | --------- | ------- | ---- | ---------------- |
- | touchable | boolean | 是 | 设置是否可点击。 |
-
-**返回值:**
-
- | 类型 | 说明 |
- | ------------------- | ----------------------------------------------- |
- | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------------------------- | ---- | ---------------- |
+| touchable | boolean | 是 | 设置是否可点击。 |
+| callback | AsyncCallback<void> | 是 | 回调函数。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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));
+})
+```
-### setKeepScreenOn
+### setOutsideTouchable(deprecated)
-setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>
+setOutsideTouchable(touchable: boolean): Promise<void>
-设置屏幕是否为常亮状态,使用Promise异步回调。
+设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。
+
+> **说明:** 从API version 9开始废弃。
+>
+> 从 API version 7开始支持。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-**参数:**
+**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------------- | ------- | ---- | ------------------------ |
-| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| --------- | ------- | ---- | ---------------- |
+| touchable | boolean | 是 | 设置是否可点击。 |
-**返回值:**
+**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
-**示例:**
+**示例:**
- ```js
- var isKeepScreenOn= true;
- let promise = windowClass.setKeepScreenOn(isKeepScreenOn);
- promise.then((data)=> {
- console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data))
- }).catch((err)=>{
- console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
- });
- ```
+```js
+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+
@@ -2048,17 +2035,17 @@ setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): voi
**示例:**
- ```js
- 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));
-
- });
- ```
+```js
+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+
@@ -2076,21 +2063,21 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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+
@@ -2109,17 +2096,17 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
**示例:**
- ```js
- 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));
-
- });
- ```
+```js
+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+
@@ -2137,41 +2124,76 @@ setTouchable(isTouchable: boolean): Promise<void>
**返回值:**
-| 类型 | 说明 |
-| ------------------- | ----------------------------------------------- |
-| Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 |
+| 类型 | 说明 |
+| ------------------- | ------------------------- |
+| Promise<void> | 无返回结果的Promise对象。 |
**示例:**
- ```js
- 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));
- });
- ```
+```js
+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));
+});
+```
## WindowStageEventType9+
WindowStage生命周期。
-**系统能力:** 以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-| 名称 | 默认值 | 说明 |
-| ---------- | ------ | -------- |
-| FOREGROUND | 1 | 切到前台 |
-| ACTIVE | 2 | 获焦状态 |
-| INACTIVE | 3 | 失焦状态 |
-| BACKGROUND | 4 | 切到后台 |
+| 名称 | 默认值 | 说明 |
+| ---------- | ------ | ---------- |
+| FOREGROUND | 1 | 切到前台。 |
+| ACTIVE | 2 | 获焦状态。 |
+| INACTIVE | 3 | 失焦状态。 |
+| BACKGROUND | 4 | 切到后台。 |
## WindowStage9+
+窗口管理器。管理各个基本窗口单元,即[Window](#window)实例。
+
下列API示例中都需在[onWindowStageCreate()](js-apis-application-ability.md#abilityonwindowstagecreate)函数中使用WindowStage的实例调用对应方法。
### getMainWindow9+
+getMainWindow(callback: AsyncCallback<Window>): void
+
+获取该WindowStage实例下的主窗口,使用callback异步回调。
+
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | --------------------------------------------- |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的主窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ windowStage.getMainWindow((err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
+ });
+ }
+}
+```
+### getMainWindow9+
+
getMainWindow(): Promise<Window>
获取该WindowStage实例下的主窗口,使用Promise异步回调。
@@ -2180,61 +2202,63 @@ getMainWindow(): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | ---------------------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前WindowStage下的主窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- let promise = windowStage.getMainWindow();
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data))
- }).catch((err)=>{
- console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
- });
- }
- }
- ```
-
-### getMainWindow9+
+| 类型 | 说明 |
+| -------------------------------- | ------------------------------------------------ |
+| Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的主窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ let promise = windowStage.getMainWindow();
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
+ });
+ }
+}
+```
+### createSubWindow9+
-getMainWindow(callback: AsyncCallback<Window>): void
+createSubWindow(name: string, callback: AsyncCallback<Window>): void
-获取该WindowStage实例下的主窗口,使用callback异步回调。
+创建该WindowStage实例下的子窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------- | ---- | --------------------------------------- |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前WindowStage下的主窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- windowStage.getMainWindow((err, data) => {
- if (err.code) {
- console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
- });
- }
- }
- ```
-
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------------------------------------- | ---- | --------------------------------------------- |
+| name | String | 是 | 子窗口的名字。 |
+| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的子窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ windowStage.createSubWindow("mySubWindow", (err, data) => {
+ if (err.code) {
+ console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));
+ windowClass.resetSize(500, 1000);
+ });
+ }
+}
+```
### createSubWindow9+
createSubWindow(name: string): Promise<Window>
@@ -2251,63 +2275,61 @@ createSubWindow(name: string): Promise<Window>
**返回值:**
-| 类型 | 说明 |
-| -------------------------------- | ------------------------------------------------- |
-| Promise<[Window](#window)> | 以Promise形式返回结果,返回当前创建的子窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- let promise = windowStage.createSubWindow("mySubWindow");
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data))
- }).catch((err)=>{
- console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
- })
- }
- }
- ```
-
-### createSubWindow9+
+| 类型 | 说明 |
+| -------------------------------- | ------------------------------------------------ |
+| Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的子窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ let promise = windowStage.createSubWindow("mySubWindow");
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
+ })
+ }
+}
+```
+### getSubWindow9+
-createSubWindow(name: string, callback: AsyncCallback<Window>): void
+getSubWindow(callback: AsyncCallback<Array<Window>>): void
-创建该WindowStage实例下的子窗口,使用callback异步回调。
+获取该WindowStage实例下的所有子窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------------------------------------- | ---- | ------------------------------ |
-| name | String | 是 | 子窗口的名字。 |
-| callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前创建的子窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- windowStage.createSubWindow("mySubWindow", (err, data) => {
- if (err.code) {
- console.error('Failed to create sub window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in create sub window. Data: ' + JSON.stringify(data));
- windowClass.resetSize(500, 1000);
- });
- }
- }
- ```
-
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
+| callback | AsyncCallback<Array<[Window](#window)>> | 是 | 回调函数。返回当前WindowStage下的所有子窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ windowStage.getSubWindow((err, data) => {
+ if (err.code) {
+ console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ windowClass = data;
+ console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));
+ });
+ }
+}
+```
### getSubWindow9+
getSubWindow(): Promise<Array<Window>>
@@ -2318,68 +2340,35 @@ getSubWindow(): Promise<Array<Window>>
**返回值:**
-| 类型 | 说明 |
-| --------------------------------------------- | ------------------------------------------------------------ |
-| Promise<Array<[Window](#window)>> | 以Promise形式返回结果,返回当前WindowStage下的所有子窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- let promise = windowStage.getSubWindow();
- promise.then((data)=> {
- windowClass = data;
- console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data))
- }).catch((err)=>{
- console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
- })
- }
- }
- ```
-
-### getSubWindow9+
-
-getSubWindow(callback: AsyncCallback<Array<Window>>): void
-
-获取该WindowStage实例下的所有子窗口,使用callback异步回调。
-
-**系统能力:** SystemCapability.WindowManager.WindowManager.Core
-
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | --------------------------------------------------- | ---- | ------------------------------------------- |
-| callback | AsyncCallback<Array<[Window](#window)>> | 是 | 回调返回当前WindowStage下的所有子窗口对象。 |
-
-**示例:**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var windowClass = null;
- windowStage.getSubWindow((err, data) => {
- if (err.code) {
- console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
- return;
- }
- windowClass = data;
- console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));
- });
- }
- }
- ```
-
+| 类型 | 说明 |
+| --------------------------------------------- | ---------------------------------------------------- |
+| Promise<Array<[Window](#window)>> | Promise对象。返回当前WindowStage下的所有子窗口对象。 |
+
+**示例:**
+
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ var windowClass = null;
+ let promise = windowStage.getSubWindow();
+ promise.then((data)=> {
+ windowClass = data;
+ console.info('Succeeded in obtaining the sub window. Data: ' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.error('Failed to obtain the sub window. Cause: ' + JSON.stringify(err));
+ })
+ }
+}
+```
### loadContent9+
loadContent(path: string, callback: AsyncCallback<void>): void
为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。
-**系统能力:** SystemCapability.WindowManager.WindowManager.Coretype为'windowSizeChange'
+**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
@@ -2390,20 +2379,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
**示例:**
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- windowStage.loadContent("pages/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))
- });
- }
- }
- ```
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ windowStage.loadContent("pages/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));
+ });
+ }
+}
+```
### on('windowStageEvent')9+
@@ -2418,21 +2408,21 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
-| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 是 | 回调返回监听到的信息。 |
+| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 是 | 回调函数。返回当前的WindowStage生命周期状态。 |
**示例:**
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var type = 'windowStageEvent';
- windowStage.on(type, (data) => {
- console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
- });
- }
- }
- ```
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ windowStage.on('windowStageEvent', (data) => {
+ console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data));
+ });
+ }
+}
+```
### off('windowStageEvent')9+
@@ -2447,16 +2437,16 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
-| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 否 | 回调返回监听到的信息。 |
+| callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 否 | 回调函数。返回当前的WindowStage生命周期状态。 |
**示例:**
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- var type = 'windowStageEvent';
- windowStage.off(type);
- }
- }
- ```
\ No newline at end of file
+```ts
+import Ability from '@ohos.application.Ability';
+class myAbility extends Ability {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ windowStage.off('windowStageEvent');
+ }
+}
+```