From dbad4708ac5eadc656fe3df8ea4adb48f0164e87 Mon Sep 17 00:00:00 2001 From: zhengjiangliang Date: Sat, 8 Oct 2022 15:33:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=AD=90=E7=B3=BB=E7=BB=9Fwi?= =?UTF-8?q?ndow=E9=94=99=E8=AF=AF=E7=A0=81=E6=96=87=E6=A1=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia4ff0c8b3c61169c5d4719213ea67e08e4039c20 Signed-off-by: zhengjiangliang --- .../reference/apis/js-apis-window.md | 2532 ++++++++++++++--- 1 file changed, 2143 insertions(+), 389 deletions(-) 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 618db8db2c..b8bb8a250f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -44,6 +44,22 @@ import window from '@ohos.window'; | TYPE_DIALOG9+ | 16 | 表示模态窗口。
**模型约束:** 此接口仅可在Stage模型下使用。
**系统接口:** 此接口为系统接口。 | | TYPE_SCREENSHOT9+ | 17 | 表示截屏窗口。
**模型约束:** 此接口仅可在Stage模型下使用。
**系统接口:** 此接口为系统接口。 | +## Configuration9+ + +创建子窗口时的参数。 + +从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | ----------------------------- | -- | -- | ------------------ | +| name | string | 是 | 是 | 子窗口名字。 | +| windowType | [WindowType](#windowtype7) | 是 | 是 | 子窗口类型。 | +| ctx | [Context](js-apis-Context.md) | 是 | 是 | 当前应用上下文信息。 | +| displayId | number | 是 | 是 | 当前物理屏幕id。 | +| parentId | string | 是 | 是 | 父窗口id。 | + ## AvoidAreaType7+ 窗口内容需要规避区域的类型枚举。 @@ -147,7 +163,7 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| type | [WindowType](#windowtype) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | +| type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | | isEnable | boolean | 是 | 否 | 当前系统栏是否显示。 | | region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 | | backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | @@ -213,7 +229,7 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | -| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。 | +| type7+ | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 | | isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | | isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | | focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | @@ -282,12 +298,15 @@ import window from '@ohos.window'; | y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 | | z | number | 否 | 是 | Z轴的平移参数,默认值为0.0。 | -## window.create7+ +## window.create(deprecated) create(id: string, type: WindowType, callback: AsyncCallback<Window>): void 创建子窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 + **模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -297,7 +316,7 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ------------------------------------ | | id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** @@ -314,12 +333,15 @@ window.create('first', window.WindowType.TYPE_APP,(err,data) => { }); ``` -## window.create7+ +## window.create(deprecated) create(id: string, type: WindowType): Promise<Window> 创建子窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 + **模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -329,7 +351,7 @@ create(id: string, type: WindowType): Promise<Window> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------- | ---- | ---------- | | id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | **返回值:** @@ -350,7 +372,7 @@ promise.then((data)=> { }); ``` -## window.create8+ +## window.create(deprecated) create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void @@ -358,6 +380,9 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi 从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -366,7 +391,7 @@ 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) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** @@ -384,7 +409,7 @@ let windowClass = null; }); ``` -## window.create8+ +## window.create(deprecated) create(ctx: Context, id: string, type: WindowType): Promise<Window> @@ -392,6 +417,9 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> 从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -400,7 +428,7 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window> | ------ | ------------------------- | ---- | ------------------------------------------------------------ | | 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) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | **返回值:** @@ -421,12 +449,88 @@ promise.then((data)=> { }); ``` -## window.find7+ +## window.createWindow9+ + +createWindow(config: Configuration, callback: AsyncCallback<Window<): void; + +创建子窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | -- | --------------------------------- | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | + +**示例:** + +```js +let windowClass = null; +let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""}; +try { + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); + }); +} catch (exception) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); +}; +``` + +## window.createWindow9+ + +createWindow(config: Configuration): Promise<Window<; + +创建子窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------- | -- | ------------------ | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ------------------------------------ | +| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | + +**示例:** + +```js +let windowClass = null; +let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""}; +try { + let promise = window.createWindow(config); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); +}; +``` + +## window.find(deprecated) find(id: string, callback: AsyncCallback<Window>): void 查找id所对应的窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -450,12 +554,15 @@ let windowClass = null; }); ``` -## window.find7+ +## window.find(deprecated) find(id: string): Promise<Window> 查找id所对应的窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -483,12 +590,45 @@ promise.then((data)=> { }); ``` -## window.getTopWindow +## window.findWindow9+ + +findWindow(name: string): Window; + +查找name所对应的窗口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| name | string | 是 | 窗口id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------- | +| [Window](#window) | 当前查找的窗口对象。 | + +**示例:** + +```js +try { + let windowClass = window.findWindow('alertWindow'); +} catch (exception) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); +}; +``` + +## window.getTopWindow(deprecated) getTopWindow(callback: AsyncCallback<Window>): void 获取当前应用内最后显示的窗口,使用callback异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 + **模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -513,12 +653,15 @@ window.getTopWindow((err, data) => { }); ``` -## window.getTopWindow +## window.getTopWindow(deprecated) getTopWindow(): Promise<Window> 获取当前应用内最后显示的窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 + **模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -542,12 +685,15 @@ promise.then((data)=> { }) ``` -## window.getTopWindow8+ +## window.getTopWindow(deprecated) getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void 获取当前应用内最后显示的窗口,使用callback异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -571,12 +717,15 @@ window.getTopWindow(this.context, (err, data) => { }); ``` -## window.getTopWindow8+ +## window.getTopWindow(deprecated) getTopWindow(ctx: Context): Promise<Window> 获取当前应用内最后显示的窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -604,6 +753,76 @@ promise.then((data)=> { }) ``` +## window.getLastWindow9+ + +getLastWindow(ctx: Context, callback: AsyncCallback<Window>): void + +获取当前应用内最后显示的窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | -- | ---------------------------------------- | +| 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)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | + +**示例:** + +```js +let windowClass = null; +try { + window.getLastWindow(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)); + }); +} catch (exception) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); +}; +``` + +## window.getLastWindow9+ + +getLastWindow(ctx: Context): Promise<Window> + +获取当前应用内最后显示的窗口,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| ctx | Context | 是 | 当前应用上下文信息。
API version 8的Context定义见[Context](js-apis-Context.md)。
API version 9的Context定义见[Context](js-apis-ability-context.md)。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | + +**示例:** + +```js +let windowClass = null; +try { + let promise = window.getLastWindow(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)); + }); +} catch (exception) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); +}; +``` + ## window.minimizeAll9+ minimizeAll(id: number, callback: AsyncCallback<void>): void @@ -632,13 +851,17 @@ display.getDefaultDisplay((err, data) => { return; } displayClass = data; - window.minimizeAll(displayClass.id, (err, data) => { - if(err.code) { - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in minimizing all windows.'); - }); + try { + window.minimizeAll(displayClass.id, (err, data) => { + if(err.code) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in minimizing all windows.'); + }); + } catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); + }; }); ``` @@ -675,12 +898,16 @@ display.getDefaultDisplay((err, data) => { return; } displayClass = data; - let promise = window.minimizeAll(displayClass.id); - promise.then((data)=> { - console.info('Succeeded in minimizing all windows.'); - }).catch((err)=>{ - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); - }) + try { + let promise = window.minimizeAll(displayClass.id); + promise.then((data)=> { + console.info('Succeeded in minimizing all windows.'); + }).catch((err)=>{ + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); + }; }); ``` @@ -756,9 +983,13 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>) **示例:** ```js -window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => { - console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); -}); +try { + window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => { + console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); +}; ``` ## window.setWindowLayoutMode9+ @@ -785,12 +1016,16 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> **示例:** ```js -let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); -promise.then((data)=> { - console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); -}) +try { + let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); + promise.then((data)=> { + console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); +}; ``` ## on('systemBarTintChange')8+ @@ -813,9 +1048,13 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v **示例:** ```js -window.on('systemBarTintChange', (data) => { - console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); -}); +try { + window.on('systemBarTintChange', (data) => { + console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); +}; ``` ## off('systemBarTintChange')8+ @@ -838,7 +1077,11 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) **示例:** ```js -window.off('systemBarTintChange'); +try { + window.off('systemBarTintChange'); +} catch (exception) { + console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); +}; ``` ## Window @@ -957,12 +1200,15 @@ promise.then((data)=> { }) ``` -### show7+ +### show(deprecated) show(callback: AsyncCallback<void>): void 显示当前窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -983,12 +1229,15 @@ windowClass.show((err, data) => { }) ``` -### show7+ +### show(deprecated) show(): Promise<void> 显示当前窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1008,6 +1257,57 @@ promise.then((data)=> { }) ``` +### showWindow9+ + +showWindow(callback: AsyncCallback<void>): void + +显示当前窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +windowClass.showWindow((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)); +}); +``` + +### showWindow9+ + +showWindow(): Promise<void> + +显示当前窗口,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let promise = windowClass.showWindow(); +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)); +}); +``` + ### showWithAnimation9+ showWithAnimation(callback: AsyncCallback<void>): void @@ -1063,12 +1363,15 @@ promise.then((data)=> { }) ``` -### destroy7+ +### destroy(deprecated) destroy(callback: AsyncCallback<void>): void 销毁当前窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1089,12 +1392,15 @@ windowClass.destroy((err, data) => { }) ``` -### destroy7+ +### destroy(deprecated) destroy(): Promise<void> 销毁当前窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1114,12 +1420,66 @@ promise.then((data)=> { }) ``` -### moveTo7+ +### destroyWindow9+ + +destroyWindow(callback: AsyncCallback<void>): void + +销毁当前窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +windowClass.destroyWindow((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)); +}) +``` + +### destroyWindow9+ + +destroyWindow(): Promise<void> + +销毁当前窗口,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let promise = windowClass.destroyWindow(); +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)); +}) +``` + +### moveTo(deprecated) moveTo(x: number, y: number, callback: AsyncCallback<void>): void 移动窗口位置,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowTo9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1143,12 +1503,15 @@ windowClass.moveTo(300, 300, (err, data)=>{ }); ``` -### moveTo7+ +### moveTo(deprecated) moveTo(x: number, y: number): Promise<void> 移动窗口位置,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowTo9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1175,12 +1538,83 @@ promise.then((data)=> { }) ``` -### resetSize7+ +### moveWindowTo9+ + +moveWindowTo(x: number, y: number, callback: AsyncCallback<void>): void + +移动窗口位置,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +try { + windowClass.moveWindowTo(300, 300, (err, data)=>{ + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); +}; +``` + +### moveWindowTo9+ + +moveWindowTo(x: number, y: number): Promise<void> + +移动窗口位置,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -- | ----- | -- | --------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +try { + let promise = windowClass.moveWindowTo(300, 300); + promise.then((data)=> { + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); +}; +``` + +### resetSize(deprecated) resetSize(width: number, height: number, callback: AsyncCallback<void>): void 改变当前窗口大小,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1203,12 +1637,15 @@ windowClass.resetSize(500, 1000, (err, data) => { }); ``` -### resetSize7+ +### resetSize(deprecated) resetSize(width: number, height: number): Promise<void> 改变当前窗口大小,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1235,6 +1672,74 @@ promise.then((data)=> { }); ``` +### resize9+ + +resize(width: number, height: number, callback: AsyncCallback<void>): void + +改变当前窗口大小,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | ------------------------ | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +try { + windowClass.resize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); +}; +``` + +### resize9+ + +resize(width: number, height: number): Promise<void> + +改变当前窗口大小,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | -- | ------------------------ | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +try { + let promise = windowClass.resize(500, 1000); + promise.then((data)=> { + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception)); +}; +``` + ### setWindowType(deprecated) setWindowType(type: WindowType, callback: AsyncCallback<void>): void @@ -1253,7 +1758,7 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** @@ -1287,7 +1792,7 @@ setWindowType(type: WindowType): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype) | 是 | 窗口类型。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | **返回值:** @@ -1307,12 +1812,87 @@ promise.then((data)=> { }); ``` -### getProperties +### setWindowMode9+ + +setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void + +设置窗口模式,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | -- | --------- | +| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let mode = window.WindowMode.FULLSCREEN; +try { + windowClass.setWindowMode(mode, (err, data) => { + if (err.code) { + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window mode. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowMode9+ + +setWindowMode(mode: WindowMode): Promise<void> + +设置窗口类型,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | -- | --------- | +| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let mode = window.WindowMode.FULLSCREEN; +try { + let promise = windowClass.setWindowMode(type); + promise.then((data)=> { + console.info('Succeeded in setting the window mode. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); +}; +``` + +### getProperties(deprecated) getProperties(callback: AsyncCallback<WindowProperties>): void 获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1333,12 +1913,15 @@ windowClass.getProperties((err, data) => { }); ``` -### getProperties +### getProperties(deprecated) getProperties(): Promise<WindowProperties> 获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1358,12 +1941,39 @@ promise.then((data)=> { }); ``` -### getAvoidArea7+ +### getWindowProperties9+ + +getWindowProperties(): WindowProperties + +获取当前窗口的属性,返回WindowProperties。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------- | ------------- | +| [WindowProperties](#windowproperties) | 当前窗口属性。 | + +**示例:** + +```js +try { + let properties = windowClass.getWindowProperties(); +} catch (exception) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); +}; +``` + +### getAvoidArea(deprecated) getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1386,12 +1996,15 @@ windowClass.getAvoidArea(type, (err, data) => { }); ``` -### getAvoidArea7+ +### getAvoidArea(deprecated) getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)> 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1418,12 +2031,46 @@ promise.then((data)=> { }); ``` -### setFullScreen +### getWindowAvoidArea9+ + +getWindowAvoidArea(type: [AvoidAreaType](#avoidareatype7)): [AvoidArea](#avoidarea7) + +获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- |----------------------------------| -- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | + +**返回值:** + +| 类型 | 说明 | +|--------------------------| ----------------- | +| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 | + +**示例:** + +```js +let type = window.AvoidAreaType.TYPE_SYSTEM; +try { + let avoidArea = windowClass.getWindowAvoidArea(type); +} catch (exception) { + console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); +}; +``` + +### setFullScreen(deprecated) setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void 设置是否为全屏状态,使用callback异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1446,12 +2093,15 @@ windowClass.setFullScreen(isFullScreen, (err, data) => { }); ``` -### setFullScreen +### setFullScreen(deprecated) setFullScreen(isFullScreen: boolean): Promise<void> 设置是否为全屏状态,使用Promise异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1478,12 +2128,15 @@ promise.then((data)=> { }); ``` -### setLayoutFullScreen7+ +### setLayoutFullScreen(deprecated) setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void 设置窗口的布局是否为全屏显示状态,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1506,12 +2159,15 @@ windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { }); ``` -### setLayoutFullScreen7+ +### setLayoutFullScreen(deprecated) setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> 设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1538,12 +2194,83 @@ promise.then((data)=> { }); ``` -### setSystemBarEnable7+ +### setWindowLayoutFullScreen9+ + +setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void + +设置窗口的布局是否为全屏显示状态,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | -- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let isLayoutFullScreen= true; +try { + windowClass.setWindowLayoutFullScreen(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)); + }); +} catch (exception) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowLayoutFullScreen9+ + +setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> + +设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------- | -- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let isLayoutFullScreen = true; +try { + let promise = windowClass.setWindowLayoutFullScreen(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)); + }); +} catch (exception) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); +}; +``` + +### setSystemBarEnable(deprecated) setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void 设置导航栏、状态栏的可见模式,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1567,12 +2294,15 @@ windowClass.setSystemBarEnable(names, (err, data) => { }); ``` -### setSystemBarEnable7+ +### setSystemBarEnable(deprecated) setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> 设置导航栏、状态栏的可见模式,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1600,55 +2330,131 @@ promise.then((data)=> { }); ``` -### setSystemBarProperties +### setWindowSystemBarEnable9+ -setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void -设置窗口内导航栏、状态栏的属性,使用callback异步回调。 +设置导航栏、状态栏的可见模式,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version7开始支持 - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' +// 此处以不显示导航栏、状态栏为例 +let names = []; +try { + windowClass.setWindowSystemBarEnable(names, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); }; -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 +### setWindowSystemBarEnable9+ -setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> -设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 +设置导航栏、状态栏的可见模式,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +// 此处以不显示导航栏、状态栏为例 +let names = []; +try { + let promise = windowClass.setWindowSystemBarEnable(names); + promise.then((data)=> { + console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); +}; +``` + +### setSystemBarProperties(deprecated) + +setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 + +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let 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(deprecated) + +setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> + +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 + +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | | SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | **返回值:** @@ -1678,6 +2484,92 @@ promise.then((data)=> { }); ``` +### setWindowSystemBarProperties(deprecated) + +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +try { + windowClass.setWindowSystemBarProperties(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)); + }); +} catch (exception) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowSystemBarProperties(deprecated) + +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> + +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +try { + let promise = windowClass.setWindowSystemBarProperties(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)); + }); +} catch (exception) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); +}; +``` + ### setPreferredOrientation9+ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void @@ -1697,13 +2589,17 @@ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<voi ```js let orientation = window.Orientation.AUTO_ROTATION; -windowClass.setPreferredOrientation(orientation, (err, data) => { - if (err.code) { - console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.setPreferredOrientation(orientation, (err, data) => { + if (err.code) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); +}; ``` ### setPreferredOrientation9+ @@ -1730,20 +2626,27 @@ setPreferredOrientation(orientation: Orientation): Promise<void> ```js let orientation = window.Orientation.AUTO_ROTATION; -let promise = windowClass.setPreferredOrientation(orientation); -promise.then((data)=> { - console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err)); -}); +try { + let promise = windowClass.setPreferredOrientation(orientation); + promise.then((data)=> { + console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); +}; ``` -### loadContent7+ +### loadContent(deprecated) loadContent(path: string, callback: AsyncCallback<void>): void 为当前窗口加载具体页面内容,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1765,12 +2668,15 @@ windowClass.loadContent('pages/page2/page2', (err, data) => { }); ``` -### loadContent7+ +### loadContent(deprecated) loadContent(path: string): Promise<void> 为当前窗口加载具体页面内容,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1795,6 +2701,73 @@ promise.then((data)=> { console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); }); ``` + +### setUIContent9+ + +setUIContent(path: string, callback: AsyncCallback<void>): void + +为当前窗口加载具体页面内容,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +try { + windowClass.setUIContent('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)); + }); +} catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); +}; +``` + +### setUIContent9+ + +setUIContent(path: string): Promise<void> + +为当前窗口加载具体页面内容,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- | ------ | -- | ------------------ | +| path | string | 是 | 设置加载页面的路径。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +try { + let promise = windowClass.setUIContent('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)); + }); +} catch (exception) { + console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); +}; +``` + ### loadContent9+ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void @@ -1822,13 +2795,17 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent('pages/page2',this.storage,(err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.loadContent('pages/page2',this.storage,(err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -1866,22 +2843,30 @@ class myAbility extends Ability { this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); let windowClass = null; - let promise = windowStage.loadContent('pages/page2',this.storage); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - }) + try { + let promise = windowStage.loadContent('pages/page2',this.storage); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` -### isShowing7+ + +### isShowing(deprecated) isShowing(callback: AsyncCallback<boolean>): void 判断当前窗口是否已显示,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -1902,12 +2887,15 @@ windowClass.isShowing((err, data) => { }); ``` -### isShowing7+ +### isShowing(deprecated) isShowing(): Promise<boolean> 判断当前窗口是否已显示,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -1927,6 +2915,31 @@ promise.then((data)=> { }); ``` +### isWindowShowing(deprecated) + +isWindowShowing(): boolean; + +判断当前窗口是否已显示。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------------------------- | +| boolean | 返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | + +**示例:** + +```js +try { + let data = windowClass.isWindowShowing(); + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); +} catch (exception) { + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); +}; +``` + ### on('windowSizeChange')7+ on(type: 'windowSizeChange', callback: Callback<Size>): void @@ -1945,9 +2958,13 @@ on(type: 'windowSizeChange', callback: Callback<Size>): void **示例:** ```js -windowClass.on('windowSizeChange', (data) => { - console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.on('windowSizeChange', (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('windowSizeChange')7+ @@ -1968,7 +2985,11 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void **示例:** ```js -windowClass.off('windowSizeChange'); +try { + windowClass.off('windowSizeChange'); +} catch (exception) { + console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('systemAvoidAreaChange')(deprecated) @@ -2021,7 +3042,6 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<[AvoidArea](#avoidarea windowClass.off('systemAvoidAreaChange'); ``` - ### on('avoidAreaChange')9+ on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void @@ -2040,9 +3060,14 @@ on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatyp **示例:** ```js -windowClass.on('avoidAreaChange', (data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); -}); +try { + windowClass.on('avoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. type:' + + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); + }); +} catch (exception) { + console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('avoidAreaChange')9+ @@ -2063,7 +3088,11 @@ off(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareaty **示例:** ```js -windowClass.off('avoidAreaChange'); +try { + windowClass.off('avoidAreaChange'); +} catch (exception) { + console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('keyboardHeightChange')7+ @@ -2084,9 +3113,13 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void **示例:** ```js -windowClass.on('keyboardHeightChange', (data) => { - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.on('keyboardHeightChange', (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('keyboardHeightChange')7+ @@ -2107,7 +3140,11 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void **示例:** ```js -windowClass.off('keyboardHeightChange'); +try { + windowClass.off('keyboardHeightChange'); +} catch (exception) { + console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('touchOutside')9+ @@ -2130,9 +3167,13 @@ on(type: 'touchOutside', callback: Callback<void>): void **示例:** ```js -windowClass.on('touchOutside', () => { - console.info('touch outside'); -}); +try { + windowClass.on('touchOutside', () => { + console.info('touch outside'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('touchOutside')9+ @@ -2155,7 +3196,11 @@ off(type: 'touchOutside', callback?: Callback<void>): void **示例:** ```js -windowClass.off('touchOutside'); +try { + windowClass.off('touchOutside'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('screenshot')9+ @@ -2176,9 +3221,13 @@ on(type: 'screenshot', callback: Callback<void>): void **示例:** ```js -windowClass.on('screenshot', () => { - console.info('screenshot happened'); -}); +try { + windowClass.on('screenshot', () => { + console.info('screenshot happened'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('screenshot')9+ @@ -2202,11 +3251,18 @@ off(type: 'screenshot', callback?: Callback<void>): void let callback = ()=>{ console.info('screenshot happened'); } -windowClass.on('screenshot', callback) -windowClass.off('screenshot', callback) - -// 如果通过on开启多个callback进行监听,同时关闭所有监听: -windowClass.off('screenshot'); +try { + windowClass.on('screenshot', callback); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +try { + windowClass.off('screenshot', callback); + // 如果通过on开启多个callback进行监听,同时关闭所有监听: + windowClass.off('screenshot'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### on('dialogTargetTouch')9+ @@ -2227,9 +3283,13 @@ on(type: 'dialogTargetTouch', callback: Callback<void>): void **示例:** ```js -windowClass.on('dialogTargetTouch', () => { - console.info('touch dialog target'); -}); +try { + windowClass.on('dialogTargetTouch', () => { + console.info('touch dialog target'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### off('dialogTargetTouch')9+ @@ -2250,7 +3310,11 @@ off(type: 'dialogTargetTouch', callback?: Callback<void>): void **示例:** ```js -windowClass.off('dialogTargetTouch'); +try { + windowClass.off('dialogTargetTouch'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; ``` ### bindDialogTarget9+ @@ -2294,15 +3358,19 @@ class TestRemoteObject extends rpc.RemoteObject { } } let token = new TestRemoteObject('testObject'); -windowClass.bindDialogTarget(token, () => { - console.info('Dialog Window Need Destroy.'); -}, (err, data) => { - if (err.code) { - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); -}); +try { + windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }, (err, data) => { + if (err.code) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); +}; ``` ### bindDialogTarget9+ @@ -2351,22 +3419,29 @@ class TestRemoteObject extends rpc.RemoteObject { } } let token = new TestRemoteObject('testObject'); -let promise = windowClass.bindDialogTarget(token, () => { - console.info('Dialog Window Need Destroy.'); -}); -promise.then((data)=> { - console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); -}); +try { + let promise = windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }); + promise.then((data)=> { + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); +}; ``` -### isSupportWideGamut8+ +### isSupportWideGamut(deprecated) isSupportWideGamut(callback: AsyncCallback<boolean>): void 判断当前窗口是否支持广色域模式,使用callback异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2387,12 +3462,15 @@ windowClass.isSupportWideGamut((err, data) => { }) ``` -### isSupportWideGamut8+ +### isSupportWideGamut(deprecated) isSupportWideGamut(): Promise<boolean> 判断当前窗口是否支持广色域模式,使用Promise异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -2412,12 +3490,66 @@ promise.then((data)=> { }); ``` -### setColorSpace8+ +### isWindowSupportWideGamut9+ + +isWindowSupportWideGamut(callback: AsyncCallback<boolean>): void + +判断当前窗口是否支持广色域模式,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | + +**示例:** + +```js +windowClass.isWindowSupportWideGamut((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)); +}); +``` + +### isWindowSupportWideGamut9+ + +isWindowSupportWideGamut(): Promise<boolean> + +判断当前窗口是否支持广色域模式,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | + +**示例:** + +```js +let promise = windowClass.isWindowSupportWideGamut(); +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)); +}); +``` + +### setColorSpace(deprecated) setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void 设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2439,12 +3571,15 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { }) ``` -### setColorSpace8+ +### setColorSpace(deprecated) setColorSpace(colorSpace:ColorSpace): Promise<void> 设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2470,12 +3605,81 @@ promise.then((data)=> { }); ``` -### getColorSpace8+ +### setWindowColorSpace9+ + +setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void + +设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ----------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +try { + windowClass.setWindowColorSpace(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)); + }); +} catch (exception) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowColorSpace9+ + +setWindowColorSpace(colorSpace:ColorSpace): Promise<void> + +设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ------------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +try { + let promise = windowClass.setWindowColorSpace(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)); + }); +} catch (exception) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); +}; +``` + +### getColorSpace(deprecated) getColorSpace(callback: AsyncCallback<ColorSpace>): void 获取当前窗口色域模式,使用callback异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2496,12 +3700,15 @@ windowClass.getColorSpace((err, data) => { }) ``` -### getColorSpace8+ +### getColorSpace(deprecated) getColorSpace(): Promise<ColorSpace> 获取当前窗口色域模式,使用Promise异步回调。 +> **说明:** +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** @@ -2521,12 +3728,35 @@ promise.then((data)=> { }); ``` -### setBackgroundColor +### getWindowColorSpace9+ + +getWindowColorSpace(): ColorSpace + +获取当前窗口色域模式。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------- | +| [ColorSpace](#colorspace) | 当前色域模式。 | + +**示例:** + +```js +let colorSpace = windowClass.getWindowColorSpace(); +``` + +### setBackgroundColor(deprecated) setBackgroundColor(color: string, callback: AsyncCallback<void>): void 设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2549,12 +3779,15 @@ windowClass.setBackgroundColor(color, (err, data) => { }); ``` -### setBackgroundColor +### setBackgroundColor(deprecated) setBackgroundColor(color: string): Promise<void> 设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2581,35 +3814,40 @@ promise.then((data)=> { }); ``` -### setWakeUpScreen()9+ +### setWindowBackgroundColor9+ -setWakeUpScreen(wakeUp: boolean): void; - -窗口唤醒屏幕。 +setWindowBackgroundColor(color: string): void -**系统接口:** 此接口为系统接口。 +设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ------- | ---- | ---------------------------- | -| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | -- | ----------------------------------------------------------------------- | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | **示例:** ```js -let wakeUp = true; -windowClass.setWakeUpScreen(wakeUp); +let color = '#00ff33'; +try { + windowClass.setWindowBackgroundColor(color); +} catch (exception) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); +}; ``` -### setBrightness +### setBrightness(deprecated) setBrightness(brightness: number, callback: AsyncCallback<void>): void 设置屏幕亮度值,使用callback异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2632,12 +3870,15 @@ windowClass.setBrightness(brightness, (err, data) => { }); ``` -### setBrightness +### setBrightness(deprecated) setBrightness(brightness: number): Promise<void> 设置屏幕亮度值,使用Promise异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2664,6 +3905,74 @@ promise.then((data)=> { }); ``` +### setWindowBrightness9+ + +setWindowBrightness(brightness: number, callback: AsyncCallback<void>): void + +设置屏幕亮度值,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let brightness = 1; +try { + windowClass.setWindowBrightness(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)); + }); +} catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowBrightness9+ + +setWindowBrightness(brightness: number): Promise<void> + +设置屏幕亮度值,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let brightness = 1; +try { + let promise = windowClass.setWindowBrightness(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)); + }); +} catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); +}; +``` + ### setDimBehind(deprecated) setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void @@ -2730,12 +4039,15 @@ promise.then((data)=> { }); ``` -### setFocusable7+ +### setFocusable(deprecated) setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void 设置点击时是否支持切换焦点窗口,使用callback异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2758,12 +4070,15 @@ windowClass.setFocusable(isFocusable, (err, data) => { }); ``` -### setFocusable7+ +### setFocusable(deprecated) setFocusable(isFocusable: boolean): Promise<void> 设置点击时是否支持切换焦点窗口,使用Promise异步回调。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2790,12 +4105,83 @@ promise.then((data)=> { }); ``` -### setKeepScreenOn +### setWindowFocusable9+ + +setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void + +设置点击时是否支持切换焦点窗口,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | -------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let isFocusable= true; +try { + windowClass.setWindowFocusable(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)); + }); +} catch (exception) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setWindowFocusable9+ + +setWindowFocusable(isFocusable: boolean): Promise<void> + +设置点击时是否支持切换焦点窗口,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | -- | -------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let isFocusable= true; +try { + let promise = windowClass.setWindowFocusable(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)); + }); +} catch (exception) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); +}; +``` + +### setKeepScreenOn(deprecated) setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void 设置屏幕是否为常亮状态,使用callback异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2818,12 +4204,15 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { }); ``` -### setKeepScreenOn +### setKeepScreenOn(deprecated) setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> 设置屏幕是否为常亮状态,使用Promise异步回调。 +> **说明:** +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2850,6 +4239,101 @@ promise.then((data) => { }); ``` +### setWindowKeepScreenOn9+ + +setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void + +设置屏幕是否为常亮状态,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | -- | ---------------------- | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let isKeepScreenOn = true; +try { + windowClass.setWindowKeepScreenOn(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)); + }); +} catch (exception) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowKeepScreenOn9+ + +setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise<void> + +设置屏幕是否为常亮状态,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------- | -- | ---------------------- | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + +```js +let isKeepScreenOn = true; +try { + let promise = windowClass.setWindowKeepScreenOn(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)); + }); +} catch (exception) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWakeUpScreen()9+ + +setWakeUpScreen(wakeUp: boolean): void; + +窗口唤醒屏幕。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ------- | ---- | ---------------------------- | +| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 | + +**示例:** + +```js +let wakeUp = true; +try { + windowClass.setWakeUpScreen(wakeUp); +} catch (exception) { + console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); +}; +``` + ### setOutsideTouchable(deprecated) setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void @@ -2916,12 +4400,15 @@ promise.then((data)=> { }); ``` -### setPrivacyMode7+ +### setPrivacyMode(deprecated) setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void 设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2945,12 +4432,15 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { }); ``` -### setPrivacyMode7+ +### setPrivacyMode(deprecated) setPrivacyMode(isPrivacyMode: boolean): Promise<void> 设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。 + **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** @@ -2977,93 +4467,106 @@ promise.then((data)=> { }); ``` -### setSnapshotSkip9+ -setSnapshotSkip(isSkip: boolean): void +### setWindowPrivacyMode9+ -截屏录屏是否忽略当前窗口。 +setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -**系统接口:** 此接口为系统接口。 +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | ---- | -------------------- | -| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------------------------- | -- | ------------------ | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + ```js -let isSkip = true; -windowClass.setSnapshotSkip(isSkip); +let isPrivacyMode = true; +try { + windowClass.setWindowPrivacyMode(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)); + }); +} catch (exception) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); +}; ``` -### setTouchable7+ +### setWindowPrivacyMode9+ -setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void +setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void> -设置窗口是否为可触状态,使用callback异步回调。 +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | -- | ------------------ | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let 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)); - -}); +let isPrivacyMode = true; +try { + let promise = windowClass.setWindowPrivacyMode(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)); + }); +} catch (exception) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); +}; ``` -### setTouchable7+ +### setSnapshotSkip9+ +setSnapshotSkip(isSkip: boolean): void -setTouchable(isTouchable: boolean): Promise<void> +截屏录屏是否忽略当前窗口。 -设置窗口是否为可触状态,使用Promise异步回调。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | - -**示例:** +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| ```js -let 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)); -}); +let isSkip = true; +try { + windowClass.setSnapshotSkip(isSkip); +} catch (exception) { + console.error('Failed to Skip. Cause: ' + JSON.stringify(exception)); +}; ``` -### setForbidSplitMove9+ +### setTouchable(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void -设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 +设置窗口是否为可触状态,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -3071,30 +4574,31 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void&g | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | +| isTouchable | boolean | 是 | 窗口是否为可触状态。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let isForbidSplitMove = true; -windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => { +let isTouchable = true; +windowClass.setTouchable(isTouchable, (err, data) => { if (err.code) { - console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data)); + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); }); ``` -### setForbidSplitMove9+ +### setTouchable(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> +setTouchable(isTouchable: boolean): Promise<void> -设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 +设置窗口是否为可触状态,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -3102,7 +4606,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | +| isTouchable | boolean | 是 | 窗口是否为可触状态。 | **返回值:** @@ -3113,95 +4617,88 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> **示例:** ```js -let isForbidSplitMove = true; -let promise = windowClass.setForbidSplitMove(isForbidSplitMove); +let isTouchable = true; +let promise = windowClass.setTouchable(isTouchable); promise.then((data)=> { - console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); }); ``` -### snapshot9+ +### setWindowTouchable9+ -snapshot(callback: AsyncCallback<image.PixelMap>): void +setWindowTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void -获取窗口截图,使用callback异步回调。 +设置窗口是否为可触状态,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | ------------------ | +| isTouchable | boolean | 是 | 窗口是否为可触状态。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.snapshot((err, data) => { - if (err.code) { - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - data.release(); // PixelMap使用完后及时释放内存 -}); +let isTouchable = true; +try { + windowClass.setWindowTouchable(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)); + }); +} catch (exception) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); +}; ``` -### snapshot9+ +### setWindowTouchable9+ -snapshot(): Promise<image.PixelMap> +setWindowTouchable(isTouchable: boolean): Promise<void> -获取窗口截图,使用Promise异步回调。 +设置窗口是否为可触状态,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | - -**示例:** - -```js -let promise = windowClass.snapshot(); -promise.then((pixelMap)=> { - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 -}).catch((err)=>{ - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); -}); -``` - -### setBlur9+ - -setBlur(radius: number): void - -设置窗口模糊。 - -**系统接口:** 此接口为系统接口。 +**参数:** -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | -- | ------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。 | -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.setBlur(4.0); +let isTouchable = true; +try { + let promise = windowClass.setWindowTouchable(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)); + }); +} catch (exception) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); +}; ``` -### setBackdropBlur9+ +### setForbidSplitMove9+ -setBackdropBlur(radius: number): void +setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void -设置窗口背景模糊。 +设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 **系统接口:** 此接口为系统接口。 @@ -3209,21 +4706,33 @@ setBackdropBlur(radius: number): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setBackdropBlur(4.0); +let isForbidSplitMove = true; +try { + windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => { + if (err.code) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data)); + }); +} catch (exception) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); +}; ``` -### setBackdropBlurStyle9+ +### setForbidSplitMove9+ -setBackdropBlurStyle(blurStyle: BlurStyle): void +setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> -设置窗口背景模糊类型。 +设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 **系统接口:** 此接口为系统接口。 @@ -3231,61 +4740,83 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | --------- | ---- | ---------------------- | -| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -windowClass.setBackdropBlurStyle(window.BlurType.THIN); +let isForbidSplitMove = true; +try { + let promise = windowClass.setForbidSplitMove(isForbidSplitMove); + promise.then((data)=> { + console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); + }); +} catch (exception) { + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); +}; ``` -### setShadow9+ - -setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void +### snapshot9+ -设置窗口边缘阴影。 +snapshot(callback: AsyncCallback<image.PixelMap>): void -**系统接口:** 此接口为系统接口。 +获取窗口截图,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | -| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | -| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | **示例:** ```js -windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +windowClass.snapshot((err, data) => { + if (err.code) { + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + data.release(); // PixelMap使用完后及时释放内存 +}); ``` -### setCornerRadius9+ - -setCornerRadius(cornerRadius: number): void +### snapshot9+ -设置窗口圆角半径。 +snapshot(): Promise<image.PixelMap> -**系统接口:** 此接口为系统接口。 +获取窗口截图,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | **示例:** ```js -windowClass.setCornerRadius(4.0); +let promise = windowClass.snapshot(); +promise.then((pixelMap)=> { + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 +}).catch((err)=>{ + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); +}); ``` ### opacity9+ @@ -3307,7 +4838,11 @@ opacity(opacity: number): void **示例:** ```js -windowClass.opacity(0.5); +try { + windowClass.opacity(0.5); +} catch (exception) { + console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); +}; ``` ### scale9+ @@ -3335,7 +4870,11 @@ let obj : window.ScaleOptions = { pivotX = 0.5; pivotY = 0.5; } -windowClass.scale(obj); +try { + windowClass.scale(obj); +} catch (exception) { + console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); +}; ``` ### rotate9+ @@ -3364,7 +4903,11 @@ let obj : window.RotateOptions = { pivotX = 0.5; pivotY = 0.5; } -windowClass.rotate(obj); +try { + windowClass.rotate(obj); +} catch (exception) { + console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); +}; ``` ### translate9+ @@ -3391,7 +4934,11 @@ let obj : window.TranslateOptions = { y : 0.0, z : 0.0 } -windowClass.translate(obj); +try { + windowClass.translate(obj); +} catch (exception) { + console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); +}; ``` ### getTransitionController9+ @@ -3447,6 +4994,139 @@ windowClass.hideWithAnimation((err, data) => { }) ``` +### setBlur9+ + +setBlur(radius: number): void + +设置窗口模糊。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | + +**示例:** + +```js +try { + windowClass.setBlur(4.0); +} catch (exception) { + console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setBackdropBlur9+ + +setBackdropBlur(radius: number): void + +设置窗口背景模糊。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | + +**示例:** + +```js +try { + windowClass.setBackdropBlur(4.0); +} catch (exception) { + console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setBackdropBlurStyle9+ + +setBackdropBlurStyle(blurStyle: BlurStyle): void + +设置窗口背景模糊类型。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------- | ---- | ---------------------- | +| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | + +**示例:** + +```js +try { + windowClass.setBackdropBlurStyle(window.BlurType.THIN); +} catch (exception) { + console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setShadow9+ + +setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void + +设置窗口边缘阴影。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | +| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | +| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | + +**示例:** + +```js +try { + windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +} catch (exception) { + console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setCornerRadius9+ + +setCornerRadius(cornerRadius: number): void + +设置窗口圆角半径。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | + +**示例:** + +```js +try { + windowClass.setCornerRadius(4.0); +} catch (exception) { + console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); +}; +``` + ## WindowStageEventType9+ WindowStage生命周期。 @@ -3503,6 +5183,7 @@ class myAbility extends Ability { } } ``` + ### getMainWindow9+ getMainWindow(): Promise<Window> @@ -3537,6 +5218,39 @@ class myAbility extends Ability { } } ``` + +### getMainWindowSync9+ + +getMainWindow(): Window; + +获取该WindowStage实例下的主窗口。 + +**模型约束:** 此接口仅可在Stage模型下使用。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------- | +| [Window](#window) | 返回当前WindowStage下的主窗口对象。 | + +**示例:** + +```ts +import Ability from '@ohos.application.Ability'; +class myAbility extends Ability { + onWindowStageCreate(windowStage) { + console.log('onWindowStageCreate'); + try { + let windowClass = windowStage.getMainWindowSync(); + } catch (exception) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); + }; + } +} +``` + ### createSubWindow9+ createSubWindow(name: string, callback: AsyncCallback<Window>): void @@ -3562,15 +5276,19 @@ class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; - windowStage.createSubWindow('mySubWindow', (err, data) => { - if (err.code) { - console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); - }); + try { + windowStage.createSubWindow('mySubWindow', (err, data) => { + if (err.code) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); + }); + } catch (exception) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); + }; } } ``` @@ -3604,16 +5322,21 @@ class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; - let promise = windowStage.createSubWindow('mySubWindow'); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); - }) + try { + let promise = windowStage.createSubWindow('mySubWindow'); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); + }; } } ``` + ### getSubWindow9+ getSubWindow(callback: AsyncCallback<Array<Window>>): void @@ -3711,13 +5434,17 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - windowStage.loadContent('pages/page2',this.storage,(err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }); + try { + windowStage.loadContent('pages/page2',this.storage,(err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3756,13 +5483,17 @@ class myAbility extends Ability { this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); let windowClass = null; - let promise = windowStage.loadContent('pages/page2',this.storage); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - }) + try { + let promise = windowStage.loadContent('pages/page2',this.storage); + promise.then((data)=> { + windowClass = data; + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }).catch((err)=>{ + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3791,13 +5522,17 @@ 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)); - }); + try { + 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)); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3826,9 +5561,15 @@ 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)); - }); + try { + windowStage.on('windowStageEvent', (data) => { + console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + + JSON.stringify(data)); + }); + } catch (exception) { + console.error('Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; } } ``` @@ -3857,7 +5598,12 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.off('windowStageEvent'); + try { + windowStage.off('windowStageEvent'); + } catch (exception) { + console.error('Failed to disable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + }; } } ``` @@ -3911,7 +5657,11 @@ import Ability from '@ohos.application.Ability'; class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); - windowStage.setShowOnLockScreen(true); + try { + windowStage.setShowOnLockScreen(true); + } catch (exception) { + console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception)); + }; } } ``` @@ -3968,9 +5718,13 @@ controller.animationForShown = (context : window.TransitionContext) => { console.info('toWindow translate end'); } ) - context.completeTransition(true) + try { + context.completeTransition(true) + } catch (exception) { + console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception)); + } console.info('complete transition end'); -} +}; ``` ## TransitionController9+ -- GitLab