diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 4f87ddaf5507b56f86e1b073135828fdd17f111e..91d9a4e985f3e52912d1ebd31d70bcda83389d7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -78,6 +78,14 @@ getDefaultDisplaySync(): Display | ------------------------------| ----------------------------------------------| | [Display](#display) | 返回默认的display对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -102,10 +110,20 @@ getAllDisplays(callback: AsyncCallback<Array<Display>>): void | -------- | ---------------------------------------------------- | ---- | ------------------------------- | | callback | AsyncCallback<Array<[Display](#display)>> | 是 | 回调函数。返回当前所有的display对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +let displayClass = null; display.getAllDisplays((err, data) => { + displayClass = data; if (err.code) { console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); return; @@ -128,11 +146,21 @@ getAllDisplays(): Promise<Array<Display>> | ----------------------------------------------- | ------------------------------------------------------- | | Promise<Array<[Display](#display)>> | Promise对象。返回当前所有的display对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +let displayClass = null; let promise = display.getAllDisplays(); promise.then((data) => { + displayClass = data; console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); }).catch((err) => { console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); @@ -143,7 +171,7 @@ promise.then((data) => { hasPrivateWindow(displayId: number): boolean -查询指定display对象上是否有可见的隐私窗口。可通过[setPrivacyMode](js-apis-window.md#setprivacymode7)接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。 +查询指定display对象上是否有可见的隐私窗口。可通过[setWindowPrivacyMode()](js-apis-window.md#setwindowprivacymode9)接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。 **系统接口:** 此接口为系统接口。 @@ -161,6 +189,14 @@ hasPrivateWindow(displayId: number): boolean | -------------------------------- |-----------------------------------------------------------------------| |boolean | 查询的display对象上是否有可见的隐私窗口。
true表示此display对象上有可见的隐私窗口,false表示此display对象上没有可见的隐私窗口。
| +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -247,6 +283,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void 获取当前默认的display对象,使用callback异步回调。 > **说明:** +> > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -260,7 +297,7 @@ getDefaultDisplay(callback: AsyncCallback<Display>): void **示例:** ```js -var displayClass = null; +let displayClass = null; display.getDefaultDisplay((err, data) => { if (err.code) { console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); @@ -278,6 +315,7 @@ getDefaultDisplay(): Promise<Display> 获取当前默认的display对象,使用Promise异步回调。 > **说明:** +> > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -291,7 +329,7 @@ getDefaultDisplay(): Promise<Display> **示例:** ```js -var displayClass = null; +let displayClass = null; let promise = display.getDefaultDisplay(); promise.then((data) => { displayClass = data; @@ -308,6 +346,7 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void 获取当前所有的display对象,使用callback异步回调。 > **说明:** +> > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -337,6 +376,7 @@ getAllDisplay(): Promise<Array<Display>> 获取当前所有的display对象,使用Promise异步回调。 > **说明:** +> > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -361,7 +401,7 @@ promise.then((data) => { ## Display 屏幕实例。描述display对象的属性和方法。 -下列API示例中都需先使用[getAllDisplay()](#displaygetalldisplay)、[getDefaultDisplay()](#displaygetdefaultdisplay)、[getDefaultDisplaySync()](#displaygetdefaultdisplaysync)中的任一方法获取到Display实例,再通过此实例调用对应方法。 +下列API示例中都需先使用[getAllDisplays()](#displaygetalldisplays9)、[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)中的任一方法获取到Display实例,再通过此实例调用对应方法。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -394,9 +434,23 @@ getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void | ----------- | --------------------------- | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | 是 | 回调函数。当获取信息成功,err为undefined,data为获取到的CutoutInfo对象;否则err为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +try { + let displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +}; + displayClass.getCutoutInfo((err, data) => { if (err.code) { console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); @@ -418,9 +472,23 @@ getCutoutInfo(): Promise<CutoutInfo> | ------------------- | ------------------------- | | Promise<[CutoutInfo](#cutoutinfo9)> | Promise对象,返回描述不可用屏幕区域的CutoutInfo对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js +try { + let displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +}; + let promise = displayClass.getCutoutInfo(); promise.then((data) => { console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen.md b/zh-cn/application-dev/reference/apis/js-apis-screen.md index 4dd8fafc283b062840c37f0725871e421898da7a..52ba0e627bee0c69ed7503c55db4b4b9b569a296 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen.md @@ -28,6 +28,14 @@ getAllScreens(callback: AsyncCallback<Array<Screen>>): void | -------- | --------------------------------------------------- | ---- | -------------------------------------- | | callback | AsyncCallback<Array<[Screen](#screen)>> | 是 | 回调函数。返回当前获取的屏幕对象集合。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -56,6 +64,14 @@ getAllScreens(): Promise<Array<Screen>> | --------------------------------------------- | ----------------------------------------- | | Promise<Array<[Screen](#screen)>> | Promise对象。返回当前获取的屏幕对象集合。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -140,6 +156,14 @@ makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number& | options | Array<[ExpandOption](#expandoption)> | 是 | 设置扩展屏幕的参数集合。 | | callback | Callback<number> | 是 | 回调函数。返回扩展屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -178,6 +202,14 @@ makeExpand(options:Array<ExpandOption>): Promise<number> | --------------------- | ----------------------------------- | | Promise<number> | Promise对象。返回扩展屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -208,6 +240,14 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncC | mirrorScreen | Array<number> | 是 | 镜像屏幕id集合。 | | callback | AsyncCallback<number> | 是 | 回调函数。返回镜像屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -247,6 +287,14 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<numb | --------------------- | ----------------------------------- | | Promise<number> | Promise对象。返回镜像屏幕的群组id。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -280,6 +328,14 @@ createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Scre | options | [VirtualScreenOption](#virtualscreenoption) | 是 | 用于创建虚拟屏幕的参数。 | | callback | AsyncCallback<[Screen](#screen)> | 是 | 回调函数,返回创建的虚拟屏幕对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -326,6 +382,14 @@ createVirtualScreen(options:VirtualScreenOption): Promise<Screen> | -------------------------------- | ------------------------------------- | | Promise<[Screen](#screen)> | Promise对象。返回创建的虚拟屏幕对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -363,6 +427,14 @@ destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void | screenId | number | 是 | 屏幕的id。 | | callback | AsyncCallback<void> | 是 | 回调函数。当销毁虚拟屏幕成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 1400002 | This operation is not access. | + **示例:** ```js @@ -400,6 +472,14 @@ destroyVirtualScreen(screenId:number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 1400002 | This operation is not access. | + **示例:** ```js @@ -433,6 +513,14 @@ setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallb | surfaceId | string | 是 | surface的id。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置虚拟屏幕surface成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -474,6 +562,14 @@ setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | ----------------------- | +| 1400001 | This is invalid screen. | + **示例:** ```js @@ -662,6 +758,14 @@ setOrientation(orientation: Orientation, callback: AsyncCallback<void>): v | orientation | [Orientation](#orientation) | 是 | 屏幕方向。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕方向成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -696,6 +800,14 @@ setOrientation(orientation: Orientation): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -724,6 +836,14 @@ setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): voi | modeIndex | number | 是 | 模式索引。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕当前显示模式成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -759,6 +879,14 @@ setScreenActiveMode(modeIndex: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -788,6 +916,14 @@ setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void; | densityDpi | number | 是 | 像素密度。支持的输入范围为80-640。 | | callback | AsyncCallback<void> | 是 | 回调函数。当设置屏幕的像素密度成功,err为undefined,否则为错误对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js @@ -823,6 +959,14 @@ setDensityDpi(densityDpi: number): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[屏幕错误码](../errorcodes/errorcode-display.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1400003 | This window manager service work abnormally. | + **示例:** ```js 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 b8bb8a250f57431c4f812b08b1dc13e53d06658c..0d28afc2ae1bc5b80f25077a4b9fa2837df5ec9f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -48,17 +48,17 @@ import window from '@ohos.window'; 创建子窗口时的参数。 -从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 +当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。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ---------- | -------------------------- | -- | ----------------------------------- | +| name | string | 是 | 子窗口名字。 | +| windowType | [WindowType](#windowtype7) | 是 | 子窗口类型。 | +| ctx | BaseContext | 否 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。不设置,则默认为空。 | +| displayId | number | 否 | 当前物理屏幕id。不设置,则默认为-1。 | +| parentId | number | 否 | 父窗口id。不设置,则默认为-1。 | ## AvoidAreaType7+ @@ -111,10 +111,10 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | | statusBarColor | string | 否 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 | +| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。 | | statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 | | navigationBarColor | string | 否 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| isNavigationBarLightIcon7+ | boolean | 否 | 是 | 导航栏图标是否为高亮状态。 | +| isNavigationBarLightIcon7+ | boolean | 否 | 是 | 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。 | | navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 | ## Orientation9+ @@ -164,7 +164,7 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | -| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。 | +| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。true表示显示;false表示不显示。 | | region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 | | backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | | contentColor | string | 是 | 否 | 系统栏文字颜色。 | @@ -203,7 +203,7 @@ import window from '@ohos.window'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ---------- | ------------- | ---- | ---- | ------------------ | -| visible9+ | boolean | 是 | 是 | 规避区域是否可见。 | +| visible9+ | boolean | 是 | 是 | 规避区域是否可见。true表示可见;false表示不可见。 | | leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | | topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | | rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | @@ -230,16 +230,16 @@ import window from '@ohos.window'; | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | | type7+ | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 | -| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | -| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | -| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | -| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。 | +| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。true表示全屏;false表示非全屏。 | +| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 | +| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。true表示可聚焦;false表示不可聚焦。 | +| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。true表示可触摸;false表示不可触摸。 | | brightness | number | 是 | 是 | 屏幕亮度, 取值范围为0~1,1表示最大亮度值。 | -| dimBehindValue(deprecated) | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持 | -| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。 | -| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。 | -| isRoundCorner(deprecated) | boolean | 是 | 是 | 窗口是否为圆角。默认为false。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持 | -| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。 | +| dimBehindValue(deprecated) | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持。 | +| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。true表示常亮;false表示不常亮。 | +| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。true表示模式开启;false表示模式关闭。 | +| isRoundCorner(deprecated) | boolean | 是 | 是 | 窗口是否为圆角。默认为false。true表示圆角;false表示非圆角。
- **说明:** 从API version 9开始废弃。
- 从 API version 7开始支持。 | +| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。true表示透明;false表示不透明。 | | id9+ | number | 是 | 否 | 窗口ID,默认值为0.0。 | ## ColorSpace8+ @@ -298,858 +298,901 @@ import window from '@ohos.window'; | y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 | | z | number | 否 | 是 | Z轴的平移参数,默认值为0.0。 | -## window.create(deprecated) +## window.createWindow9+ -create(id: string, type: WindowType, callback: AsyncCallback<Window>): void +createWindow(config: Configuration, callback: AsyncCallback<Window>): void 创建子窗口,使用callback异步回调。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 - -**模型约束:** 此接口仅可在FA模型下使用。 - **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------ | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | -- | --------------------------------- | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300001 | This is repeat operation. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; -window.create('first', window.WindowType.TYPE_APP,(err,data) => { - if(err.code){ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); -}); +let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: 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.create(deprecated) - -create(id: string, type: WindowType): Promise<Window> - -创建子窗口,使用Promise异步回调。 +## window.createWindow9+ -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 +createWindow(config: Configuration): Promise<Window> -**模型约束:** 此接口仅可在FA模型下使用。 +创建子窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ---------- | -| id | string | 是 | 窗口id。 | -| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------- | -- | ------------------ | +| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| -------------------------------- | ------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | -**示例:** - -```js -let windowClass = null; -let promise = window.create('first', window.WindowType.TYPE_APP); -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)); -}); -``` - -## window.create(deprecated) - -create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void - -创建子窗口,使用callback异步回调,其中Context详见[Context](js-apis-Context.md)。 - -从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**参数:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| 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](#windowtype7) | 是 | 窗口类型。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300001 | This is repeat operation. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; - window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - if (err.code) { - console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); -}); +let config = {name: "alertWindow", windowType: window.WindowType.TYPE_SYSTEM_ALERT, ctx: 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.create(deprecated) - -create(ctx: Context, id: string, type: WindowType): Promise<Window> - -创建子窗口,使用Promise异步回调,其中Context详见[Context](js-apis-Context.md)。 +## window.findWindow9+ -从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。 +findWindow(name: string): Window -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。 +查找id所对应的窗口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ------------------------------------------------------------ | -| 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](#windowtype7) | 是 | 窗口类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| name | string | 是 | 窗口id。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | +| 类型 | 说明 | +| ----------------- | ------------------- | +| [Window](#window) | 当前查找的窗口对象。 | **示例:** ```js -let windowClass = null; -let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT); -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)); -}); +try { + let windowClass = window.findWindow('alertWindow'); +} catch (exception) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.createWindow9+ +## window.getLastWindow9+ -createWindow(config: Configuration, callback: AsyncCallback<Window<): void; +getLastWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void -创建子窗口,使用callback异步回调。 +获取当前应用内最后显示的窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | -- | --------------------------------- | -| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | +| -------- | -------------------------------------- | -- | ---------------------------------------- | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; -let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""}; try { - window.createWindow(config, (err, data) => { + window.getLastWindow(this.context, (err, data) => { if (err.code) { - console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } windowClass = data; - console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); - windowClass.resetSize(500, 1000); + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); }; ``` -## window.createWindow9+ +## window.getLastWindow9+ -createWindow(config: Configuration): Promise<Window<; +getLastWindow(ctx: BaseContext): Promise<Window> -创建子窗口,使用callback异步回调。 +获取当前应用内最后显示的窗口,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | -| ------ | -------------------------------- | -- | ------------------ | -| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | **返回值:** | 类型 | 说明 | -| -------------------------------- | ------------------------------------ | -| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | +| -------------------------------- | ------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300006 | This window context is abnormal. | **示例:** ```js let windowClass = null; -let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""}; try { - let promise = window.createWindow(config); + let promise = window.getLastWindow(this.context); promise.then((data)=> { windowClass = data; - console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); }; ``` -## window.find(deprecated) - -find(id: string, callback: AsyncCallback<Window>): void +## window.minimizeAll9+ +minimizeAll(id: number, callback: AsyncCallback<void>): void -查找id所对应的窗口,使用callback异步回调。 +最小化某显示设备下的所有窗口。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | ------------------------------------ | -| id | string | 是 | 窗口id。 | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前查找到的窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------- | +| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号。 | +| callback | AsyncCallback<void> | 是 | 回调信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; - window.find('alertWindow', (err, data) => { - if (err.code) { - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); -}); -``` +import display from '@ohos.display' +import window from '@ohos.window' -## window.find(deprecated) +try { + displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); + return; +}; -find(id: string): Promise<Window> +try { + window.minimizeAll(displayClass.id, (err) => { + 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)); +}; +``` -查找id所对应的窗口,使用Promise异步回调。 +## window.minimizeAll9+ +minimizeAll(id: number): Promise<void> -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 +最小化某显示设备下的所有窗口。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------- | -| id | string | 是 | 窗口id。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------- | +| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | ------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前查找的窗口对象。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; -let promise = window.find('alertWindow'); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); -}); -``` - -## window.findWindow9+ - -findWindow(name: string): Window; - -查找name所对应的窗口。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------- | -| name | string | 是 | 窗口id。 | - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ------------------- | -| [Window](#window) | 当前查找的窗口对象。 | +import display from '@ohos.display' +import window from '@ohos.window' -**示例:** +try { + displayClass = display.getDefaultDisplaySync(); +} catch (exception) { + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); + return; +}; -```js try { - let windowClass = window.findWindow('alertWindow'); + let promise = window.minimizeAll(displayClass.id); + promise.then(()=> { + 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 find the Window. Cause: ' + JSON.stringify(exception)); + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); }; ``` -## window.getTopWindow(deprecated) - -getTopWindow(callback: AsyncCallback<Window>): void - -获取当前应用内最后显示的窗口,使用callback异步回调。 +## window.toggleShownStateForAllAppWindows9+ +toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 +多窗口快速切换时隐藏或者恢复应用窗口。 -**模型约束:** 此接口仅可在FA模型下使用。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------------------------- | ---- | -------------------------------------------- | -| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------- | +| callback | AsyncCallback<void> | 是 | 回调信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; -window.getTopWindow((err, data) => { +window.toggleShownStateForAllAppWindows((err) => { if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); return; } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}); + console.info('Succeeded in toggling shown state for all app windows.'); +}) ``` -## window.getTopWindow(deprecated) - -getTopWindow(): Promise<Window> - -获取当前应用内最后显示的窗口,使用Promise异步回调。 +## window.toggleShownStateForAllAppWindows9+ +toggleShownStateForAllAppWindows(): Promise<void> -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 +多窗口快速切换时隐藏或者恢复应用窗口。 -**模型约束:** 此接口仅可在FA模型下使用。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| -------------------------------- | ----------------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; -let promise = window.getTopWindow(); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +let promise = window.toggleShownStateForAllAppWindows(); +promise.then(()=> { + console.info('Succeeded in toggling shown state for all app windows.'); }).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); }) ``` -## window.getTopWindow(deprecated) - -getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void +## window.setWindowLayoutMode9+ +setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void -获取当前应用内最后显示的窗口,使用callback异步回调。 +设置窗口布局模式。 -> **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 +**系统接口:** 此接口为系统接口。 **系统能力:** 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)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------- | +| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式。 | +| callback | AsyncCallback<void> | 是 | 回调信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; -window.getTopWindow(this.context, (err, data) => { - if (err.code) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}); +try { + window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err) => { + if(err.code) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window layout mode.'); + }); +} catch (exception) { + console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); +}; ``` -## window.getTopWindow(deprecated) - -getTopWindow(ctx: Context): Promise<Window> +## window.setWindowLayoutMode9+ +setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> -获取当前应用内最后显示的窗口,使用Promise异步回调。 +设置窗口布局模式。 -> **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 +**系统接口:** 此接口为系统接口。 **系统能力:** 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)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------- | +| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | ----------------------------------------------- | -| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let windowClass = null; -let promise = window.getTopWindow(this.context); -promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); -}) +try { + let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); + promise.then(()=> { + console.info('Succeeded in setting window layout mode.'); + }).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)); +}; ``` -## window.getLastWindow9+ +## window.on('systemBarTintChange')8+ -getLastWindow(ctx: Context, callback: AsyncCallback<Window>): void +on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): 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)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | +| callback | Callback<[SystemBarTintState](#systembartintstate)> | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 | **示例:** ```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)); + window.on('systemBarTintChange', (data) => { + console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); }; ``` -## window.getLastWindow9+ +## window.off('systemBarTintChange')8+ + +off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void -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对象。返回当前应用内最后显示的窗口对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | +| callback | Callback<[SystemBarTintState](#systembartintstate)> | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 | **示例:** ```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)); - }); + window.off('systemBarTintChange'); } catch (exception) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); }; ``` -## window.minimizeAll9+ -minimizeAll(id: number, callback: AsyncCallback<void>): void +## 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 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------- | -| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号 | -| callback | AsyncCallback<void> | 是 | 回调信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** ```js -import display from '@ohos.display' -import window from '@ohos.window' - -let displayClass = null; -display.getDefaultDisplay((err, data) => { - if(err.code) { +let windowClass = null; +window.create('first', window.WindowType.TYPE_APP,(err,data) => { + if(err.code){ + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); return; } - displayClass = data; - 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)); - }; + windowClass = data; + console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data)); }); ``` -## window.minimizeAll9+ -minimizeAll(id: number): Promise<void> +## 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 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------- | -| id | number | 是 | 显示设备[Display](js-apis-display.md#display)的ID号 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ---------- | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | --------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | **示例:** ```js -import display from '@ohos.display' -import window from '@ohos.window' - -let displayClass = null; -display.getDefaultDisplay((err, data) => { - if(err.code) { - return; - } - displayClass = data; - 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)); - }; +let windowClass = null; +let promise = window.create('first', window.WindowType.TYPE_APP); +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)); }); ``` -## window.toggleShownStateForAllAppWindows9+ -toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void +## window.create(deprecated) -多窗口快速切换时隐藏或者恢复应用窗口。 +create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback<Window>): void -**系统接口:** 此接口为系统接口。 +创建子窗口,使用callback异步回调,其中Context详见[Context](js-apis-Context.md)。 + +从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------- | -| callback | AsyncCallback<void> | 是 | 回调信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。 | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前创建的子窗口对象。 | **示例:** ```js -window.toggleShownStateForAllAppWindows((err, data) => { +let windowClass = null; + window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { if (err.code) { - console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); + console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in toggling shown state for all app windows.'); -}) + windowClass = data; + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + windowClass.resetSize(500, 1000); +}); ``` -## window.toggleShownStateForAllAppWindows9+ -toggleShownStateForAllAppWindows(): Promise<void> +## window.create(deprecated) -多窗口快速切换时隐藏或者恢复应用窗口。 +create(ctx: BaseContext, id: string, type: WindowType): Promise<Window> -**系统接口:** 此接口为系统接口。 +创建子窗口,使用Promise异步回调,其中Context详见[Context](js-apis-Context.md)。 + +从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 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-service-extension-context.md)。 | +| id | string | 是 | 窗口id。 | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | --------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前创建的子窗口对象。 | **示例:** ```js -let promise = window.toggleShownStateForAllAppWindows(); +let windowClass = null; +let promise = window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { - console.info('Succeeded in toggling shown state for all app windows. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); -}) + console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); +}); ``` -## window.setWindowLayoutMode9+ -setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void +## window.find(deprecated) -设置窗口布局模式。 +find(id: string, callback: AsyncCallback<Window>): void -**系统接口:** 此接口为系统接口。 +查找id所对应的窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------- | -| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式 | -| callback | AsyncCallback<void> | 是 | 回调信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| id | string | 是 | 窗口id。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前查找到的窗口对象。 | **示例:** ```js -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)); -}; +let windowClass = null; + window.find('alertWindow', (err, data) => { + if (err.code) { + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); +}); ``` -## window.setWindowLayoutMode9+ -setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> +## window.find(deprecated) -设置窗口布局模式。 +find(id: string): Promise<Window> -**系统接口:** 此接口为系统接口。 +查找id所对应的窗口,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------- | -| mode | [WindowLayoutMode](#windowlayoutmode9) | 是 | 设置的窗口布局模式 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| id | string | 是 | 窗口id。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | ------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前查找的窗口对象。 | **示例:** ```js -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)); -}; +let windowClass = null; +let promise = window.find('alertWindow'); +promise.then((data)=> { + windowClass = data; + console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); +}); ``` -## on('systemBarTintChange')8+ +## window.getTopWindow(deprecated) -on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void +getTopWindow(callback: AsyncCallback<Window>): void -开启状态栏、导航栏属性变化的监听。 +获取当前应用内最后显示的窗口,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 + +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | -| callback | Callback<[SystemBarTintState](#systembartintstate)> | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | -------------------------------------------- | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -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)); -}; +let windowClass = null; +window.getTopWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); ``` -## off('systemBarTintChange')8+ +## window.getTopWindow(deprecated) -off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void +getTopWindow(): Promise<Window> -关闭状态栏、导航栏属性变化的监听。 +获取当前应用内最后显示的窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 + +**模型约束:** 此接口仅可在FA模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | -| callback | Callback<[SystemBarTintState](#systembartintstate)> | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -try { - window.off('systemBarTintChange'); -} catch (exception) { - console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); -}; +let windowClass = null; +let promise = window.getTopWindow(); +promise.then((data)=> { + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); +}) ``` -## Window - -当前窗口实例,窗口管理器管理的基本单元。 - -下列API示例中都需先使用[getTopWindow()](#windowgettopwindow)、[create()](#windowcreate7)、[find()](#windowfind7)中的任一方法获取到Window实例,再通过此实例调用对应方法。 - -### hide7+ +## window.getTopWindow(deprecated) -hide (callback: AsyncCallback<void>): void +getTopWindow(ctx: BaseContext, callback: AsyncCallback<Window>): void -隐藏当前窗口,使用callback异步回调。 +获取当前应用内最后显示的窗口,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | +| callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 | + +**示例:** ```js -windowClass.hide((err, data) => { +let windowClass = null; +window.getTopWindow(this.context, (err, data) => { if (err.code) { - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); -}) + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); +}); ``` -### hide7+ +## window.getTopWindow(deprecated) -hide(): Promise<void> +getTopWindow(ctx: BaseContext): Promise<Window> -隐藏当前窗口,使用Promise异步回调。 +获取当前应用内最后显示的窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| ctx | BaseContext | 是 | 当前应用上下文信息。
FA模型的Context定义见[Context](js-apis-Context.md)。
Stage模型的Context定义见[Context](js-apis-ability-context.md)。 | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------------------- | +| Promise<[Window](#window)> | Promise对象。返回当前应用内最后显示的窗口对象。 | **示例:** ```js -let promise = windowClass.hide(); +let windowClass = null; +let promise = window.getTopWindow(this.context); promise.then((data)=> { - console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data)); + windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); }) ``` -### hideWithAnimation9+ +## Window -hideWithAnimation(callback: AsyncCallback<void>): void +当前窗口实例,窗口管理器管理的基本单元。 -隐藏当前窗口,过程中播放动画,使用callback异步回调。 +下列API示例中都需先使用[getLastWindow()](#windowgetlastwindow9)、[createWindow()](#windowcreatewindow9)、[findWindow()](#windowfindwindow9)中的任一方法获取到Window实例,再通过此实例调用对应方法。 + +### hide7+ + +hide (callback: AsyncCallback<void>): void + +隐藏当前窗口,使用callback异步回调。 **系统接口:** 此接口为系统接口。 @@ -1161,23 +1204,31 @@ hideWithAnimation(callback: AsyncCallback<void>): void | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -windowClass.hideWithAnimation((err, data) => { +windowClass.hide((err) => { if (err.code) { - console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data)); + console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data)); }) ``` -### hideWithAnimation9+ +### hide7+ -hideWithAnimation(): Promise<void> +hide(): Promise<void> -隐藏当前窗口,过程中播放动画,使用Promise异步回调。 +隐藏当前窗口,使用Promise异步回调。 **系统接口:** 此接口为系统接口。 @@ -1189,25 +1240,32 @@ hideWithAnimation(): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -let promise = windowClass.hideWithAnimation(); -promise.then((data)=> { - console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); +let promise = windowClass.hide(); +promise.then(()=> { + console.info('Succeeded in hiding the window.'); }).catch((err)=>{ - console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); }) ``` -### show(deprecated) +### hideWithAnimation9+ -show(callback: AsyncCallback<void>): void +hideWithAnimation(callback: AsyncCallback<void>): void -显示当前窗口,使用callback异步回调。 +隐藏当前窗口,过程中播放动画,使用callback异步回调。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1217,26 +1275,35 @@ show(callback: AsyncCallback<void>): void | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | + **示例:** ```js -windowClass.show((err, data) => { +windowClass.hideWithAnimation((err) => { if (err.code) { - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + console.info('Succeeded in hiding the window with animation.'); }) ``` -### show(deprecated) +### hideWithAnimation9+ -show(): Promise<void> +hideWithAnimation(): Promise<void> -显示当前窗口,使用Promise异步回调。 +隐藏当前窗口,过程中播放动画,使用Promise异步回调。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1246,14 +1313,24 @@ show(): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | + **示例:** ```js -let promise = windowClass.show(); -promise.then((data)=> { - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); +let promise = windowClass.hideWithAnimation(); +promise.then(()=> { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); }) ``` @@ -1271,15 +1348,23 @@ showWindow(callback: AsyncCallback<void>): void | -------- | ------------------------- | -- | --------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -windowClass.showWindow((err, data) => { +windowClass.showWindow((err) => { 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)); + console.info('Succeeded in showing the window.'); }); ``` @@ -1297,12 +1382,20 @@ showWindow(): Promise<void> | ------------------- | ----------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js let promise = windowClass.showWindow(); -promise.then((data)=> { - console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); +promise.then(()=> { + console.info('Succeeded in showing the window.'); }).catch((err)=>{ console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); }); @@ -1324,15 +1417,25 @@ showWithAnimation(callback: AsyncCallback<void>): void | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | + **示例:** ```js -windowClass.showWithAnimation((err, data) => { +windowClass.showWithAnimation((err) => { if (err.code) { console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); + console.info('Succeeded in showing the window with animation.'); }) ``` @@ -1352,71 +1455,24 @@ showWithAnimation(): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | -**示例:** - -```js -let promise = windowClass.showWithAnimation(); -promise.then((data)=> { - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); -}) -``` - -### destroy(deprecated) - -destroy(callback: AsyncCallback<void>): void - -销毁当前窗口,使用callback异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -windowClass.destroy((err, data) => { - if (err.code) { - console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); -}) -``` - -### destroy(deprecated) - -destroy(): Promise<void> - -销毁当前窗口,使用Promise异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**返回值:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | +| 1300004 | This operation is not access. | **示例:** ```js -let promise = windowClass.destroy(); -promise.then((data)=> { - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); +let promise = windowClass.showWithAnimation(); +promise.then(()=> { + console.info('Succeeded in showing the window with animation.'); }).catch((err)=>{ - console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); }) ``` @@ -1434,15 +1490,24 @@ destroyWindow(callback: AsyncCallback<void>): void | -------- | ------------------------- | -- | --------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -windowClass.destroyWindow((err, data) => { +windowClass.destroyWindow((err) => { 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)); + console.info('Succeeded in destroying the window.'); }) ``` @@ -1460,81 +1525,23 @@ destroyWindow(): Promise<void> | ------------------- | ------------------------ | | 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 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -windowClass.moveTo(300, 300, (err, data)=>{ - if (err.code) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); - -}); -``` - -### moveTo(deprecated) - -moveTo(x: number, y: number): Promise<void> - -移动窗口位置,使用Promise异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowTo9-1)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------- | -| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | -| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +**错误码:** -**返回值:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let promise = windowClass.moveTo(300, 300); -promise.then((data)=> { - console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); +let promise = windowClass.destroyWindow(); +promise.then(()=> { + console.info('Succeeded in destroying the window.'); }).catch((err)=>{ - console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); }) ``` @@ -1554,16 +1561,25 @@ moveWindowTo(x: number, y: number, callback: AsyncCallback<void>): void | y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js try { - windowClass.moveWindowTo(300, 300, (err, data)=>{ + windowClass.moveWindowTo(300, 300, (err)=>{ 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)); + console.info('Succeeded in moving the window.'); }); } catch (exception) { console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); @@ -1591,13 +1607,22 @@ moveWindowTo(x: number, y: number): Promise<void> | ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js try { let promise = windowClass.moveWindowTo(300, 300); - promise.then((data)=> { - console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + promise.then(()=> { + console.info('Succeeded in moving the window.'); }).catch((err)=>{ console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); }); @@ -1606,75 +1631,9 @@ try { }; ``` -### resetSize(deprecated) +### resize9+ -resetSize(width: number, height: number, callback: AsyncCallback<void>): void - -改变当前窗口大小,使用callback异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------------------- | -| width | number | 是 | 目标窗口的宽度,单位为px。 | -| height | number | 是 | 目标窗口的高度,单位为px。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -windowClass.resetSize(500, 1000, (err, data) => { - if (err.code) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); -}); -``` - -### resetSize(deprecated) - -resetSize(width: number, height: number): Promise<void> - -改变当前窗口大小,使用Promise异步回调。 - -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------------- | -| width | number | 是 | 目标窗口的宽度,单位为px。 | -| height | number | 是 | 目标窗口的高度,单位为px。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | - -**示例:** - -```js -let promise = windowClass.resetSize(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)); -}); -``` - -### resize9+ - -resize(width: number, height: number, callback: AsyncCallback<void>): void +resize(width: number, height: number, callback: AsyncCallback<void>): void 改变当前窗口大小,使用callback异步回调。 @@ -1688,16 +1647,25 @@ resize(width: number, height: number, callback: AsyncCallback<void>): void | height | number | 是 | 目标窗口的高度,单位为px。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js try { - windowClass.resize(500, 1000, (err, data) => { + windowClass.resize(500, 1000, (err) => { 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)); + console.info('Succeeded in changing the window size.'); }); } catch (exception) { console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); @@ -1725,13 +1693,22 @@ resize(width: number, height: number): Promise<void> | ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js try { let promise = windowClass.resize(500, 1000); - promise.then((data)=> { - console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + promise.then(()=> { + console.info('Succeeded in changing the window size.'); }).catch((err)=>{ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); }); @@ -1740,78 +1717,6 @@ try { }; ``` -### setWindowType(deprecated) - -setWindowType(type: WindowType, callback: AsyncCallback<void>): void - -设置窗口类型,使用callback异步回调。 - -**系统接口:** 此接口为系统接口。 - -> **说明:** 从API version 9开始废弃。 -> -> 从 API version 7开始支持。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -let type = window.WindowType.TYPE_APP; -windowClass.setWindowType(type, (err, data) => { - if (err.code) { - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); -}); -``` - -### setWindowType(deprecated) - -setWindowType(type: WindowType): Promise<void> - -设置窗口类型,使用Promise异步回调。 - -**系统接口:** 此接口为系统接口。 - -> **说明:** 从API version 9开始废弃。 -> -> 从 API version 7开始支持。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------------- | ---- | ---------- | -| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | - -**示例:** - -```js -let type = window.WindowType.TYPE_APP; -let promise = windowClass.setWindowType(type); -promise.then((data)=> { - console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); -}); -``` - ### setWindowMode9+ setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void @@ -1826,20 +1731,29 @@ setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | -- | --------- | -| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 | +| mode | [WindowMode](#windowmode7) | 是 | 窗口模式。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js let mode = window.WindowMode.FULLSCREEN; try { - windowClass.setWindowMode(mode, (err, data) => { + windowClass.setWindowMode(mode, (err) => { 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)); + console.info('Succeeded in setting the window mode.'); }); } catch (exception) { console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); @@ -1860,7 +1774,7 @@ setWindowMode(mode: WindowMode): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | -- | --------- | -| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 | +| mode | [WindowMode](#windowmode7) | 是 | 窗口模式。 | **返回值:** @@ -1868,14 +1782,23 @@ setWindowMode(mode: WindowMode): Promise<void> | ------------------- | ----------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```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)); + promise.then(()=> { + console.info('Succeeded in setting the window mode.'); }).catch((err)=>{ console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err)); }); @@ -1884,231 +1807,314 @@ try { }; ``` -### getProperties(deprecated) - -getProperties(callback: AsyncCallback<WindowProperties>): void +### getWindowProperties9+ -获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 +getWindowProperties(): WindowProperties -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 +获取当前窗口的属性,返回WindowProperties。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调函数。返回当前窗口属性。 | +| 类型 | 说明 | +| ------------------------------------- | ------------- | +| [WindowProperties](#windowproperties) | 当前窗口属性。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -windowClass.getProperties((err, data) => { - if (err.code) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); -}); +try { + let properties = windowClass.getWindowProperties(); +} catch (exception) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); +}; ``` -### getProperties(deprecated) - -getProperties(): Promise<WindowProperties> +### getWindowAvoidArea9+ -获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 +getWindowAvoidArea(type: AvoidAreaType): AvoidArea -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---- |----------------------------------| -- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | + **返回值:** -| 类型 | 说明 | -| ---------------------------------------------------- | ------------------------------- | -| Promise<[WindowProperties](#windowproperties)> | Promise对象。返回当前窗口属性。 | +| 类型 | 说明 | +|--------------------------| ----------------- | +| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let promise = windowClass.getProperties(); -promise.then((data)=> { - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); -}); +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)); +}; ``` -### getWindowProperties9+ +### setWindowLayoutFullScreen9+ -getWindowProperties(): WindowProperties +setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -获取当前窗口的属性,返回WindowProperties。 +设置窗口的布局是否为全屏显示状态,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** +**参数:** -| 类型 | 说明 | -| ------------------------------------- | ------------- | -| [WindowProperties](#windowproperties) | 当前窗口属性。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | -- | --------- | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏显示;false表示非全屏显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let isLayoutFullScreen= true; try { - let properties = windowClass.getWindowProperties(); + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { + 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.'); + }); } catch (exception) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); }; ``` -### getAvoidArea(deprecated) - -getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void +### setWindowLayoutFullScreen9+ -获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。 +setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。 +设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | -| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回窗口内容规避区域。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------- | -- | ------------------------------------------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏显示;false表示非全屏显示。 | -**示例:** +**返回值:** -```js -let type = window.AvoidAreaType.TYPE_SYSTEM; -windowClass.getAvoidArea(type, (err, data) => { - if (err.code) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); -}); -``` +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | -### getAvoidArea(deprecated) +**错误码:** -getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)> +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。 +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。 +**示例:** + +```js +let isLayoutFullScreen = true; +try { + let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + promise.then(()=> { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }).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)); +}; +``` + +### setWindowSystemBarEnable9+ + +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void + +设置导航栏、状态栏的可见模式,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ |----------------------------------| ---- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | -- | --------- | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | -**返回值:** +**错误码:** -| 类型 | 说明 | -|-----------------------------------------| ----------------------------------- | -| Promise<[AvoidArea](#avoidarea7)> | Promise对象。返回窗口内容规避区域。 | +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let type = window.AvoidAreaType.TYPE_SYSTEM; -let promise = windowClass.getAvoidArea(type); -promise.then((data)=> { - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); -}); +// 此处以不显示导航栏、状态栏为例 +let names = []; +try { + windowClass.setWindowSystemBarEnable(names, (err) => { + 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.'); + }); +} catch (exception) { + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); +}; ``` -### getWindowAvoidArea9+ +### setWindowSystemBarEnable9+ -getWindowAvoidArea(type: [AvoidAreaType](#avoidareatype7)): [AvoidArea](#avoidarea7) +setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> -获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。 +设置导航栏、状态栏的可见模式,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- |----------------------------------| -- | ------------------------------------------------------------ | -| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** | 类型 | 说明 | -|--------------------------| ----------------- | -| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let type = window.AvoidAreaType.TYPE_SYSTEM; +// 此处以不显示导航栏、状态栏为例 +let names = []; try { - let avoidArea = windowClass.getWindowAvoidArea(type); + let promise = windowClass.setWindowSystemBarEnable(names); + promise.then(()=> { + console.info('Succeeded in setting the system bar to be invisible.'); + }).catch((err)=>{ + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); + }); } catch (exception) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); }; ``` -### setFullScreen(deprecated) - -setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void +### setWindowSystemBarProperties9+ -设置是否为全屏状态,使用callback异步回调。 +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------- | ---- | ---------------------------------------------- | -| isFullScreen | boolean | 是 | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -let isFullScreen = true; -windowClass.setFullScreen(isFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); -}); +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +try { + windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => { + 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.'); + }); +} catch (exception) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); +}; ``` -### setFullScreen(deprecated) - -setFullScreen(isFullScreen: boolean): Promise<void> +### setWindowSystemBarProperties9+ -设置是否为全屏状态,使用Promise异步回调。 +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------- | ---- | ---------------------------------------------- | -| isFullScreen | boolean | 是 | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | **返回值:** @@ -2116,65 +2122,93 @@ setFullScreen(isFullScreen: boolean): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -let isFullScreen = true; -let promise = windowClass.setFullScreen(isFullScreen); -promise.then((data)=> { - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); -}); +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(()=> { + console.info('Succeeded in setting the system bar properties.'); + }).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)); +}; ``` -### setLayoutFullScreen(deprecated) - -setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void +### setPreferredOrientation9+ -设置窗口的布局是否为全屏显示状态,使用callback异步回调。 +setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。 +设置窗口的显示方向属性,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let isLayoutFullScreen= true; -windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { - if (err.code) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); -}); +let orientation = window.Orientation.AUTO_ROTATION; +try { + windowClass.setPreferredOrientation(orientation, (err) => { + if (err.code) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window orientation.'); + }); +} catch (exception) { + console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); +}; ``` -### setLayoutFullScreen(deprecated) - -setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> +### setPreferredOrientation9+ -设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 +setPreferredOrientation(orientation: Orientation): Promise<void> -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。 +设置窗口的显示方向属性,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------- | ---- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | **返回值:** @@ -2182,134 +2216,181 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + **示例:** ```js -let isLayoutFullScreen = true; -let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); -promise.then((data)=> { - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); -}); +let orientation = window.Orientation.AUTO_ROTATION; +try { + let promise = windowClass.setPreferredOrientation(orientation); + promise.then(()=> { + console.info('Succeeded in setting the window orientation.'); + }).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)); +}; ``` -### setWindowLayoutFullScreen9+ +### setUIContent9+ -setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void +setUIContent(path: string, callback: AsyncCallback<void>): void -设置窗口的布局是否为全屏显示状态,使用callback异步回调。 +为当前窗口加载具体页面内容,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------------------------- | -- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| -------- | ------------------------- | -- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```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)); + windowClass.setUIContent('pages/page2/page2', (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; - } - console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); + } + console.info('Succeeded in loading the content.'); }); } catch (exception) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); }; ``` -### setWindowLayoutFullScreen9+ +### setUIContent9+ -setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> +setUIContent(path: string): Promise<void> -设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 +为当前窗口加载具体页面内容,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | -| ------------------ | ------- | -- | ------------------------------------------------------------ | -| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | - +| ---- | ------ | -- | ------------------ | +| path | string | 是 | 设置加载页面的路径。 | + **返回值:** | 类型 | 说明 | | ------------------- | ------------------------ | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```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)); + let promise = windowClass.setUIContent('pages/page2/page2'); + promise.then(()=> { + console.info('Succeeded in loading the content.'); }).catch((err)=>{ - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); + console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); }; ``` -### setSystemBarEnable(deprecated) +### loadContent9+ -setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void +loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void -设置导航栏、状态栏的可见模式,使用callback异步回调。 +为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 +**模型约束:** 此接口仅可在Stage模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | +| path | string | 是 | 设置加载页面的路径。 | +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** -```js -// 此处以不显示导航栏、状态栏为例 -let names = []; -windowClass.setSystemBarEnable(names, (err, data) => { - if (err.code) { - console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); - return; +```ts +class myAbility extends Ability { + storage : LocalStorage + onWindowStageCreate(windowStage) { + this.storage = new LocalStorage(); + this.storage.setOrCreate('storageSimpleProp',121); + console.log('onWindowStageCreate'); + try { + windowStage.loadContent('pages/page2',this.storage,(err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); + } catch (exception) { + console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + }; } - console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); -}); +} ``` -### setSystemBarEnable(deprecated) +### loadContent9+ -setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> +loadContent(path: string, storage: LocalStorage): Promise<void> -设置导航栏、状态栏的可见模式,使用Promise异步回调。 +为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 +**模型约束:** 此接口仅可在Stage模型下使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----- | ---- | ------------------------------------------------------------ | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | +| path | string | 是 | 设置加载页面的路径。 | +| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | **返回值:** @@ -2317,515 +2398,481 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** -```js -// 此处以不显示导航栏、状态栏为例 -let names = []; -let promise = windowClass.setSystemBarEnable(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)); -}); +```ts +class myAbility extends Ability { + storage : LocalStorage + onWindowStageCreate(windowStage) { + this.storage = new LocalStorage(); + this.storage.setOrCreate('storageSimpleProp',121); + console.log('onWindowStageCreate'); + let windowClass = null; + try { + let promise = windowStage.loadContent('pages/page2',this.storage); + promise.then(()=> { + windowClass = data; + console.info('Succeeded in loading the content.'); + }).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)); + }; + } +} ``` -### setWindowSystemBarEnable9+ +### isWindowShowing9+ -setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void +isWindowShowing(): boolean -设置导航栏、状态栏的可见模式,使用callback异步回调。 +判断当前窗口是否已显示。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | -- | --------- | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 类型 | 说明 | +| ------- | ------------------------------------------------------------------ | +| boolean | 当前窗口是否已显示。true表示当前窗口已显示,false则表示当前窗口未显示。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -// 此处以不显示导航栏、状态栏为例 -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)); - }); + let data = windowClass.isWindowShowing(); + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); } catch (exception) { - console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); }; ``` -### setWindowSystemBarEnable9+ +### on('windowSizeChange')7+ -setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> +on(type: 'windowSizeChange', callback: Callback<Size>): void -设置导航栏、状态栏的可见模式,使用Promise异步回调。 +开启窗口尺寸变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ | -| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------ | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------ | ---- | -------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 | +| callback | Callback<[Size](#size7)> | 是 | 回调函数。返回当前的窗口尺寸。 | **示例:** ```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)); + 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 set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); }; ``` -### setSystemBarProperties(deprecated) - -setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void +### off('windowSizeChange')7+ -设置窗口内导航栏、状态栏的属性,使用callback异步回调。 +off(type: 'windowSizeChange', callback?: Callback<Size>): void -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。 +关闭窗口尺寸变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------- | ---- | -------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 | +| callback | Callback<[Size](#size)> | 否 | 回调函数。返回当前的窗口尺寸。 | **示例:** ```js -let SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version7开始支持 - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' +try { + windowClass.off('windowSizeChange'); +} catch (exception) { + console.error('Failed to disable the listener for window size changes. 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(deprecated) - -setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> +### on('avoidAreaChange')9+ -设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 +on(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void -> **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。 +开启系统规避区变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------------------------------| ---- |--------------------------------------| +| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 是 | 回调函数。返回当前规避区以及规避区类型。| **示例:** ```js -let SystemBarProperties={ - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version7开始支持 - isStatusBarLightIcon: true, - isNavigationBarLightIcon:false, - //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff', - navigationBarContentColor:'#00ffff' +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)); }; -let promise = windowClass.setSystemBarProperties(SystemBarProperties); -promise.then((data)=> { - console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); -}); ``` -### setWindowSystemBarProperties(deprecated) +### off('avoidAreaChange')9+ -setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void +off(type: 'avoidAreaChange', callback: Callback<{AvoidAreaType, AvoidArea}>): void -设置窗口内导航栏、状态栏的属性,使用callback异步回调。 +关闭系统规避区变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |-----------------------------------------------------------------------------|-----|------------------------------------| +| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 否 | 回调函数。返回当前规避区以及规避区类型。| **示例:** ```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)); - }); + windowClass.off('avoidAreaChange'); } catch (exception) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); + console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); }; ``` -### setWindowSystemBarProperties(deprecated) +### on('keyboardHeightChange')7+ -setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> +on(type: 'keyboardHeightChange', callback: Callback<number>): void -设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 +开启键盘高度变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | +| callback | Callback<number> | 是 | 回调函数。返回当前的键盘高度。 | **示例:** ```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)); + 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 set the system bar properties. Cause: ' + JSON.stringify(exception)); + console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); }; ``` -### setPreferredOrientation9+ +### off('keyboardHeightChange')7+ -setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void +off(type: 'keyboardHeightChange', callback?: Callback<number>): void -设置窗口的显示方向属性,使用callback异步回调。 +关闭键盘高度变化的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | +| callback | Callback<number> | 否 | 回调函数。返回当前的键盘高度。 | **示例:** ```js -let orientation = window.Orientation.AUTO_ROTATION; 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)); - }); + windowClass.off('keyboardHeightChange'); } catch (exception) { - console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); + console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); }; ``` -### setPreferredOrientation9+ +### on('touchOutside')9+ -setPreferredOrientation(orientation: Orientation): Promise<void> +on(type: 'touchOutside', callback: Callback<void>): void -设置窗口的显示方向属性,使用Promise异步回调。 +开启本窗口区域范围外的点击事件的监听。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| Orientation | [Orientation](#orientation9) | 是 | 窗口显示方向的属性。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | +| callback | Callback<void> | 是 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | **示例:** ```js -let orientation = window.Orientation.AUTO_ROTATION; 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)); + windowClass.on('touchOutside', () => { + console.info('touch outside'); }); } catch (exception) { - console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); }; ``` -### loadContent(deprecated) +### off('touchOutside')9+ -loadContent(path: string, callback: AsyncCallback<void>): void +off(type: 'touchOutside', callback?: Callback<void>): void -为当前窗口加载具体页面内容,使用callback异步回调。 +关闭本窗口区域范围外的点击事件的监听。 -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------------- | -| path | string | 是 | 设置加载页面的路径。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | +| callback | Callback<number> | 否 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | **示例:** ```js -windowClass.loadContent('pages/page2/page2', (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); -}); +try { + windowClass.off('touchOutside'); +} catch (exception) { + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); +}; ``` -### loadContent(deprecated) - -loadContent(path: string): Promise<void> +### on('screenshot')9+ -为当前窗口加载具体页面内容,使用Promise异步回调。 +on(type: 'screenshot', callback: Callback<void>): void -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。 +开启截屏事件的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | -------------------- | -| path | string | 是 | 设置加载页面的路径。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | +| callback | Callback<void> | 是 | 回调函数。发生截屏事件时的回调。 | -**返回值:** +**示例:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +```js +try { + windowClass.on('screenshot', () => { + console.info('screenshot happened'); + }); +} catch (exception) { + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); +}; +``` + +### off('screenshot')9+ + +off(type: 'screenshot', callback?: Callback<void>): void + +关闭截屏事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | +| callback | Callback<void> | 否 | 回调函数。发生截屏事件时的回调。 | **示例:** ```js -let promise = windowClass.loadContent('pages/page2/page2'); -promise.then((data)=> { - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); -}); +let callback = ()=>{ + console.info('screenshot happened'); +} +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)); +}; ``` -### setUIContent9+ +### on('dialogTargetTouch')9+ -setUIContent(path: string, callback: AsyncCallback<void>): void +on(type: 'dialogTargetTouch', callback: Callback<void>): void -为当前窗口加载具体页面内容,使用callback异步回调。 +开启模态窗口目标窗口的点击事件的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | -- | -------------------- | -| path | string | 是 | 设置加载页面的路径。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | +| callback | Callback<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)); + windowClass.on('dialogTargetTouch', () => { + console.info('touch dialog target'); }); } catch (exception) { - console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); + console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); }; ``` -### setUIContent9+ +### off('dialogTargetTouch')9+ -setUIContent(path: string): Promise<void> +off(type: 'dialogTargetTouch', callback?: Callback<void>): void -为当前窗口加载具体页面内容,使用Promise异步回调。 +关闭模态窗口目标窗口的点击事件的监听。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---- | ------ | -- | ------------------ | -| path | string | 是 | 设置加载页面的路径。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------ | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | +| callback | Callback<void> | 否 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | **示例:** ```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)); - }); + windowClass.off('dialogTargetTouch'); } catch (exception) { - console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); + console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); }; ``` -### loadContent9+ +### bindDialogTarget9+ -loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void -为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。 +绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。 -**模型约束:** 此接口仅可在Stage模型下使用。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| path | string | 是 | 设置加载页面的路径。 | -| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | +| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | -**示例:** +**错误码:** -```ts -class myAbility extends Ability { - storage : LocalStorage - onWindowStageCreate(windowStage) { - this.storage = new LocalStorage(); - this.storage.setOrCreate('storageSimpleProp',121); - console.log('onWindowStageCreate'); - 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)); - }; +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + +**示例:** + +```js +class MyDeathRecipient { + onRemoteDied() { + console.log('server died'); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; } } +let token = new TestRemoteObject('testObject'); +try { + windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }, (err) => { + if (err.code) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in binding dialog target.'); + }); +} catch (exception) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); +}; ``` -### loadContent9+ +### bindDialogTarget9+ -loadContent(path: string, storage: LocalStorage): Promise<void> +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> -为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。 +绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。 -**模型约束:** 此接口仅可在Stage模型下使用。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| path | string | 是 | 设置加载页面的路径。 | -| storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | +| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | **返回值:** @@ -2833,354 +2880,525 @@ loadContent(path: string, storage: LocalStorage): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** -```ts -class myAbility extends Ability { - storage : LocalStorage - onWindowStageCreate(windowStage) { - this.storage = new LocalStorage(); - this.storage.setOrCreate('storageSimpleProp',121); - console.log('onWindowStageCreate'); - let windowClass = null; - 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)); - }; +```js +class MyDeathRecipient { + onRemoteDied() { + console.log('server died'); + } +} +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; } } +let token = new TestRemoteObject('testObject'); +try { + let promise = windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); + }); + promise.then(()=> { + console.info('Succeeded in binding dialog target.'); + }).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)); +}; ``` -### isShowing(deprecated) - -isShowing(callback: AsyncCallback<boolean>): void +### isWindowSupportWideGamut9+ -判断当前窗口是否已显示,使用callback异步回调。 +isWindowSupportWideGamut(callback: AsyncCallback<boolean>): void -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 +判断当前窗口是否支持广色域模式,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -windowClass.isShowing((err, data) => { +windowClass.isWindowSupportWideGamut((err, data) => { if (err.code) { - console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); }); ``` -### isShowing(deprecated) - -isShowing(): Promise<boolean> +### isWindowSupportWideGamut9+ -判断当前窗口是否已显示,使用Promise异步回调。 +isWindowSupportWideGamut(): Promise<boolean> -> **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 +判断当前窗口是否支持广色域模式,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let promise = windowClass.isShowing(); +let promise = windowClass.isWindowSupportWideGamut(); promise.then((data)=> { - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); }); ``` -### isWindowShowing(deprecated) +### setWindowColorSpace9+ -isWindowShowing(): boolean; +setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void -判断当前窗口是否已显示。 +设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** +**参数:** -| 类型 | 说明 | -| ------- | ------------------------------------------------------- | -| boolean | 返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ----------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js try { - let data = windowClass.isWindowShowing(); - console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); + windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { + if (err.code) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window colorspace.'); + }); } catch (exception) { - console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); }; ``` -### on('windowSizeChange')7+ +### setWindowColorSpace9+ -on(type: 'windowSizeChange', callback: Callback<Size>): void +setWindowColorSpace(colorSpace:ColorSpace): Promise<void> -开启窗口尺寸变化的监听。 +设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------ | ---- | -------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 | -| callback | Callback<[Size](#size7)> | 是 | 回调函数。返回当前的窗口尺寸。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | ------------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js try { - windowClass.on('windowSizeChange', (data) => { - console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT); + promise.then(()=> { + console.info('Succeeded in setting window colorspace.'); + }).catch((err)=>{ + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); }; ``` -### off('windowSizeChange')7+ +### getWindowColorSpace9+ -off(type: 'windowSizeChange', callback?: Callback<Size >): void +getWindowColorSpace(): ColorSpace -关闭窗口尺寸变化的监听。 +获取当前窗口色域模式。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------- | ---- | -------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 | -| callback | Callback<[Size](#size)> | 否 | 回调函数。返回当前的窗口尺寸。 | +| 类型 | 说明 | +| ------------------------- | ------------- | +| [ColorSpace](#colorspace) | 当前色域模式。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -try { - windowClass.off('windowSizeChange'); -} catch (exception) { - console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); -}; +let colorSpace = windowClass.getWindowColorSpace(); ``` -### on('systemAvoidAreaChange')(deprecated) +### setWindowBackgroundColor9+ -on(type: 'systemAvoidAreaChange', callback: Callback<[AvoidArea](#avoidarea7)>): void +setWindowBackgroundColor(color: string): void -开启系统规避区变化的监听。 -> **说明:** 从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。 -> -> 从 API version 7开始支持。 +设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------| ---- | ------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回当前规避区。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | -- | ----------------------------------------------------------------------- | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -**示例:** +**错误码:** -```js -windowClass.on('systemAvoidAreaChange', (data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); -}); -``` +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -### off('systemAvoidAreaChange')(deprecated) +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | -off(type: 'systemAvoidAreaChange', callback?: Callback<[AvoidArea](#avoidarea7)>): void +**示例:** -关闭系统规避区变化的监听。 -> **说明:** 从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。 -> -> 从 API version 7开始支持。 +```js +let color = '#00ff33'; +try { + windowClass.setWindowBackgroundColor(color); +} catch (exception) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowBrightness9+ + +setWindowBrightness(brightness: number, callback: AsyncCallback<void>): void + +设置屏幕亮度值,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------| ---- | ------------------------------------------------------- | -| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<[AvoidArea](#avoidarea7)> | 否 | 回调函数。返回当前规避区。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -windowClass.off('systemAvoidAreaChange'); +let brightness = 1; +try { + windowClass.setWindowBrightness(brightness, (err) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness.'); + }); +} catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); +}; ``` -### on('avoidAreaChange')9+ +### setWindowBrightness9+ -on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void +setWindowBrightness(brightness: number): Promise<void> -开启系统规避区变化的监听。 +设置屏幕亮度值,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |------------------------------------------------------------------| ---- |--------------------------------------| -| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 是 | 回调函数。返回当前规避区以及规避区类型。| +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | -- | --------------------------------- | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let brightness = 1; 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)); + let promise = windowClass.setWindowBrightness(brightness); + promise.then(()=> { + console.info('Succeeded in setting the brightness.'); + }).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); }; ``` -### off('avoidAreaChange')9+ +### setWindowFocusable9+ -off(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}>): void +setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void -关闭系统规避区变化的监听。 +设置点击时是否支持切换焦点窗口,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- |-----------------------------------------------------------------------------|-----|------------------------------------| -| type | string | 是 | 监听事件,固定为'avoidAreaChange',即系统规避区变化事件。 | -| callback | Callback<{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}> | 否 | 回调函数。返回当前规避区以及规避区类型。| +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | ------------------------------------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let isFocusable= true; try { - windowClass.off('avoidAreaChange'); + windowClass.setWindowFocusable(isFocusable, (err) => { + 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.'); + }); } catch (exception) { - console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); }; ``` -### on('keyboardHeightChange')7+ +### setWindowFocusable9+ -on(type: 'keyboardHeightChange', callback: Callback<number>): void +setWindowFocusable(isFocusable: boolean): Promise<void> -开启键盘高度变化的监听。 +设置点击时是否支持切换焦点窗口,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | -| callback | Callback { - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + let promise = windowClass.setWindowFocusable(isFocusable); + promise.then(()=> { + console.info('Succeeded in setting the window to be focusable.'); + }).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); }; ``` -### off('keyboardHeightChange')7+ +### setWindowKeepScreenOn9+ -off(type: 'keyboardHeightChange', callback?: Callback<number>): void +setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void -关闭键盘高度变化的监听。 +设置屏幕是否为常亮状态,使用callback异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 | -| callback | Callback<number> | 否 | 回调函数。返回当前的键盘高度。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | -- | ---------------------------------------------------- | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let isKeepScreenOn = true; try { - windowClass.off('keyboardHeightChange'); + windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err) => { + 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.'); + }); } catch (exception) { - console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); }; ``` -### on('touchOutside')9+ - -on(type: 'touchOutside', callback: Callback<void>): void +### setWindowKeepScreenOn9+ -开启本窗口区域范围外的点击事件的监听。 +setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise<void> -**系统接口:** 此接口为系统接口。 +设置屏幕是否为常亮状态,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | -| callback | Callback { - console.info('touch outside'); + let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn); + promise.then(() => { + console.info('Succeeded in setting the screen to be always on.'); + }).catch((err)=>{ + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); }); } catch (exception) { - console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); }; ``` -### off('touchOutside')9+ +### setWakeUpScreen()9+ -off(type: 'touchOutside', callback?: Callback<void>): void +setWakeUpScreen(wakeUp: boolean): void -关闭本窗口区域范围外的点击事件的监听。 +窗口唤醒屏幕。 **系统接口:** 此接口为系统接口。 @@ -3188,140 +3406,241 @@ off(type: 'touchOutside', callback?: Callback<void>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'touchOutside',即本窗口范围外的点击事件。 | -| callback | Callback<number> | 否 | 回调函数。当点击事件发生在本窗口范围之外的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ------- | ---- | ---------------------------- | +| wakeUp | boolean | 是 | 是否设置唤醒屏幕。true表示唤醒;false表示不唤醒。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let wakeUp = true; try { - windowClass.off('touchOutside'); + windowClass.setWakeUpScreen(wakeUp); } catch (exception) { - console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); }; ``` -### on('screenshot')9+ +### setWindowPrivacyMode9+ -on(type: 'screenshot', callback: Callback<void>): void +setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -开启截屏事件的监听。 +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需要权限:** ohos.permission.PRIVACE_WINDOW + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | -| callback | Callback<void> | 是 | 回调函数。发生截屏事件时的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------------------------- | -- | ------------------------------------------------------ | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js +let isPrivacyMode = true; try { - windowClass.on('screenshot', () => { - console.info('screenshot happened'); + windowClass.setWindowPrivacyMode(isPrivacyMode, (err) => { + 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.'); }); } catch (exception) { - console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); }; ``` -### off('screenshot')9+ +### setWindowPrivacyMode9+ -off(type: 'screenshot', callback?: Callback<void>): void +setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void> -关闭截屏事件的监听。 +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需要权限:** ohos.permission.PRIVACE_WINDOW + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'screenshot',即截屏事件。 | -| callback | Callback<void> | 否 | 回调函数。发生截屏事件时的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | -- | ----------------------------------------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------ | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | **示例:** ```js -let callback = ()=>{ - console.info('screenshot happened'); -} -try { - windowClass.on('screenshot', callback); -} catch (exception) { - console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); -}; +let isPrivacyMode = true; try { - windowClass.off('screenshot', callback); - // 如果通过on开启多个callback进行监听,同时关闭所有监听: - windowClass.off('screenshot'); + let promise = windowClass.setWindowPrivacyMode(isPrivacyMode); + promise.then(()=> { + console.info('Succeeded in setting the window to privacy mode.'); + }).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + }); } catch (exception) { - console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); }; ``` -### on('dialogTargetTouch')9+ +### setSnapshotSkip9+ +setSnapshotSkip(isSkip: boolean): void -on(type: 'dialogTargetTouch', callback: Callback<void>): void +截屏录屏是否忽略当前窗口。 -开启模态窗口目标窗口的点击事件的监听。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | -| callback | Callback<void>| 是 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +```js +let isSkip = true; +try { + windowClass.setSnapshotSkip(isSkip); +} catch (exception) { + console.error('Failed to Skip. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setWindowTouchable9+ + +setWindowTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为可触状态,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | -- | ----------------------------------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let isTouchable = true; try { - windowClass.on('dialogTargetTouch', () => { - console.info('touch dialog target'); + windowClass.setWindowTouchable(isTouchable, (err) => { + 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.'); }); } catch (exception) { - console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); }; ``` -### off('dialogTargetTouch')9+ +### setWindowTouchable9+ -off(type: 'dialogTargetTouch', callback?: Callback<void>): void +setWindowTouchable(isTouchable: boolean): Promise<void> -关闭模态窗口目标窗口的点击事件的监听。 +设置窗口是否为可触状态,使用Promise异步回调。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 监听事件,固定为'dialogTargetTouch',即模态窗口目标窗口的点击事件。 | -| callback | Callback<void> | 否 | 回调函数。当点击事件发生在模态窗口目标窗口的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | -- | ----------------------------------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js +let isTouchable = true; try { - windowClass.off('dialogTargetTouch'); + let promise = windowClass.setWindowTouchable(isTouchable); + promise.then(()=> { + console.info('Succeeded in setting the window to be touchable.'); + }).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + }); } catch (exception) { - console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); }; ``` -### bindDialogTarget9+ +### setForbidSplitMove9+ -bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void +setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void -绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。 +设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 **系统接口:** 此接口为系统接口。 @@ -3329,55 +3648,42 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, c **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------- | ---- | -------------------- | -| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | -| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | **示例:** ```js -class MyDeathRecipient { - onRemoteDied() { - console.log('server died'); - } -} -class TestRemoteObject extends rpc.RemoteObject { - constructor(descriptor) { - super(descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - isObjectDead(): boolean { - return false; - } -} -let token = new TestRemoteObject('testObject'); +let isForbidSplitMove = true; try { - windowClass.bindDialogTarget(token, () => { - console.info('Dialog Window Need Destroy.'); - }, (err, data) => { + windowClass.setForbidSplitMove(isForbidSplitMove, (err) => { if (err.code) { - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); + console.info('Succeeded in forbidding window moving in split screen mode.'); }); } catch (exception) { - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); + console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); }; ``` -### bindDialogTarget9+ +### setForbidSplitMove9+ -bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> +setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> -绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。 +设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 **系统接口:** 此接口为系统接口。 @@ -3385,10 +3691,9 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 | -| deathCallback | Callback<void> | 是 | 模态窗口销毁监听。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 | **返回值:** @@ -3396,198 +3701,540 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | -------------------------------------------- | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service work abnormally. | + **示例:** ```js -class MyDeathRecipient { - onRemoteDied() { - console.log('server died'); +let isForbidSplitMove = true; +try { + let promise = windowClass.setForbidSplitMove(isForbidSplitMove); + promise.then(()=> { + console.info('Succeeded in forbidding window moving in split screen mode.'); + }).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)); +}; +``` + +### snapshot9+ + +snapshot(callback: AsyncCallback<image.PixelMap>): void + +获取窗口截图,使用callback异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```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使用完后及时释放内存 +}); +``` + +### snapshot9+ + +snapshot(): Promise<image.PixelMap> + +获取窗口截图,使用Promise异步回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | + +**示例:** + +```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)); +}); +``` + +### opacity9+ + +opacity(opacity: number): void + +设置窗口透明度。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | --------------------- | +| opacity | number | 是 | 透明度,范围0.0~1.0。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.opacity(0.5); +} catch (exception) { + console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); +}; +``` + +### scale9+ + +scale(scaleOptions: ScaleOptions): void + +设置窗口缩放参数。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------------ | ---- | ---------- | +| scaleOptions | [ScaleOptions](#scaleoptions9) | 是 | 缩放参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let obj : window.ScaleOptions = { + x : 2.0, + y : 1.0, + pivotX = 0.5; + pivotY = 0.5; } -class TestRemoteObject extends rpc.RemoteObject { - constructor(descriptor) { - super(descriptor); - } - addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { - return true; - } - isObjectDead(): boolean { - return false; - } +try { + windowClass.scale(obj); +} catch (exception) { + console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); +}; +``` + +### rotate9+ + +rotate(rotateOptions: RotateOptions): void + +设置窗口旋转参数。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | -------------------------------- | ---- | ---------- | +| rotateOptions | [RotateOptions](#rotateoptions9) | 是 | 旋转参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let obj : window.RotateOptions = { + x : 1.0, + y : 1.0, + z : 45.0, + pivotX = 0.5; + pivotY = 0.5; } -let token = new TestRemoteObject('testObject'); 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)); - }); + windowClass.rotate(obj); } catch (exception) { - console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); + console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); }; ``` -### isSupportWideGamut(deprecated) +### translate9+ -isSupportWideGamut(callback: AsyncCallback<boolean>): void +translate(translateOptions: TranslateOptions): void -判断当前窗口是否支持广色域模式,使用callback异步回调。 +设置窗口平移参数。 -> **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。 +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | -------------------------------------- | ---- | ---------- | +| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```js -windowClass.isSupportWideGamut((err, data) => { +let obj : window.TranslateOptions = { + x : 100.0, + y : 0.0, + z : 0.0 +} +try { + windowClass.translate(obj); +} catch (exception) { + console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); +}; +``` + +### getTransitionController9+ + + getTransitionController(): TransitionController + +获取窗口属性转换控制器。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------- | ---------------- | +| [TransitionController](#transitioncontroller9) | 属性转换控制器。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +let controller = windowClass.getTransitionController(); // 获取属性转换控制器 +controller.animationForHidden = (context : window.TransitionContext) => { + let toWindow = context.toWindow + animateTo({ + duration: 1000, // 动画时长 + tempo: 0.5, // 播放速率 + curve: Curve.EaseInOut, // 动画曲线 + delay: 0, // 动画延迟 + iterations: 1, // 播放次数 + playMode: PlayMode.Normal, // 动画模式 + onFinish: ()=> { + context.completeTransition(true) + } + }, () => { + let obj : window.TranslateOptions = { + x : 100.0, + y : 0.0, + z : 0.0 + } + toWindow.translate(obj); // 设置动画过程中的属性转换 + console.info('toWindow translate end'); + } + ) + console.info('complete transition end'); +} +windowClass.hideWithAnimation((err, data) => { if (err.code) { - console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); + console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); + console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); }) ``` -### isSupportWideGamut(deprecated) +### setBlur9+ + +setBlur(radius: number): void + +设置窗口模糊。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```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表示关闭窗口背景模糊。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | + +**示例:** + +```js +try { + windowClass.setBackdropBlur(4.0); +} catch (exception) { + console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); +}; +``` + +### setBackdropBlurStyle9+ + +setBackdropBlurStyle(blurStyle: BlurStyle): void + +设置窗口背景模糊类型。 + +**系统接口:** 此接口为系统接口。 -isSupportWideGamut(): Promise<boolean> +**系统能力:** SystemCapability.WindowManager.WindowManager.Core -判断当前窗口是否支持广色域模式,使用Promise异步回调。 +**参数:** -> **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。 +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------- | ---- | ---------------------- | +| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** -**返回值:** +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------ | -| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```js -let promise = windowClass.isSupportWideGamut(); -promise.then((data)=> { - console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); -}); +try { + windowClass.setBackdropBlurStyle(window.BlurType.THIN); +} catch (exception) { + console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); +}; ``` -### isWindowSupportWideGamut9+ +### setShadow9+ -isWindowSupportWideGamut(callback: AsyncCallback<boolean>): void +setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void -判断当前窗口是否支持广色域模式,使用callback异步回调。 +设置窗口边缘阴影。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- | -| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | +| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | +| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```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)); -}); +try { + windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +} catch (exception) { + console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); +}; ``` -### isWindowSupportWideGamut9+ +### setCornerRadius9+ -isWindowSupportWideGamut(): Promise<boolean> +setCornerRadius(cornerRadius: number): void -判断当前窗口是否支持广色域模式,使用Promise异步回调。 +设置窗口圆角半径。 + +**系统接口:** 此接口为系统接口。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** +**参数:** -| 类型 | 说明 | -| ---------------------- | ------------------------------------------------------------------------------------ | -| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | -------------------- | +| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300004 | This operation is not access. | **示例:** ```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)); -}); +try { + windowClass.setCornerRadius(4.0); +} catch (exception) { + console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); +}; ``` -### setColorSpace(deprecated) +### show(deprecated) -setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void +show(callback: AsyncCallback<void>): void -设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 +显示当前窗口,使用callback异步回调。 > **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | ------------ | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { +windowClass.show((err) => { if (err.code) { - console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); + console.info('Succeeded in showing the window.'); }) ``` -### setColorSpace(deprecated) +### show(deprecated) -setColorSpace(colorSpace:ColorSpace): Promise<void> +show(): Promise<void> -设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 +显示当前窗口,使用Promise异步回调。 > **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | -------------- | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | - **返回值:** | 类型 | 说明 | @@ -3597,204 +4244,192 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> **示例:** ```js -let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT); -promise.then((data)=> { - console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)); +let promise = windowClass.show(); +promise.then(()=> { + console.info('Succeeded in showing the window.'); }).catch((err)=>{ - console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); -}); + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); +}) ``` -### setWindowColorSpace9+ +### destroy(deprecated) -setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void +destroy(callback: AsyncCallback<void>): void -设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 +销毁当前窗口,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | -- | ----------- | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| 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)); -}; +windowClass.destroy((err) => { + if (err.code) { + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window.'); +}) ``` -### setWindowColorSpace9+ - -setWindowColorSpace(colorSpace:ColorSpace): Promise<void> +### destroy(deprecated) -设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 +destroy(): Promise<void> -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +销毁当前窗口,使用Promise异步回调。 -**参数:** +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。 -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | -- | ------------- | -| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------ | +| 类型 | 说明 | +| ------------------- | ------------------------- | | 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)); -}; +let promise = windowClass.destroy(); +promise.then(()=> { + console.info('Succeeded in destroying the window.'); +}).catch((err)=>{ + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); +}) ``` -### getColorSpace(deprecated) +### moveTo(deprecated) -getColorSpace(callback: AsyncCallback<ColorSpace>): void +moveTo(x: number, y: number, callback: AsyncCallback<void>): void -获取当前窗口色域模式,使用callback异步回调。 +移动窗口位置,使用callback异步回调。 > **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | -| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数。当获取成功,err为undefined,data为当前色域模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.getColorSpace((err, data) => { +windowClass.moveTo(300, 300, (err)=>{ if (err.code) { - console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); -}) + console.info('Succeeded in moving the window.'); + +}); ``` -### getColorSpace(deprecated) +### moveTo(deprecated) -getColorSpace(): Promise<ColorSpace> +moveTo(x: number, y: number): Promise<void> -获取当前窗口色域模式,使用Promise异步回调。 +移动窗口位置,使用Promise异步回调。 > **说明:** -> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowto9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** - -| 类型 | 说明 | -| ---------------------------------------- | ------------------------------- | -| Promise<[ColorSpace](#colorspace)> | Promise对象。返回当前色域模式。 | - -**示例:** - -```js -let promise = windowClass.getColorSpace(); -promise.then((data)=> { - console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); -}); -``` - -### getWindowColorSpace9+ - -getWindowColorSpace(): ColorSpace - -获取当前窗口色域模式。 +**参数:** -**系统能力:** SystemCapability.WindowManager.WindowManager.Core +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------- | +| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 | +| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 | **返回值:** -| 类型 | 说明 | -| ------------------------- | ------------- | -| [ColorSpace](#colorspace) | 当前色域模式。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let colorSpace = windowClass.getWindowColorSpace(); +let promise = windowClass.moveTo(300, 300); +promise.then(()=> { + console.info('Succeeded in moving the window.'); +}).catch((err)=>{ + console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); +}) ``` -### setBackgroundColor(deprecated) +### resetSize(deprecated) -setBackgroundColor(color: string, callback: AsyncCallback<void>): void +resetSize(width: number, height: number, callback: AsyncCallback<void>): void -设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +改变当前窗口大小,使用callback异步回调。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let color = '#00ff33'; -windowClass.setBackgroundColor(color, (err, data) => { +windowClass.resetSize(500, 1000, (err) => { if (err.code) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); + console.info('Succeeded in changing the window size.'); }); ``` -### setBackgroundColor(deprecated) +### resetSize(deprecated) -setBackgroundColor(color: string): Promise<void> +resetSize(width: number, height: number): Promise<void> -设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +改变当前窗口大小,使用Promise异步回调。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| width | number | 是 | 目标窗口的宽度,单位为px。 | +| height | number | 是 | 目标窗口的高度,单位为px。 | **返回值:** @@ -3805,222 +4440,262 @@ setBackgroundColor(color: string): Promise<void> **示例:** ```js -let color = '#00ff33'; -let promise = windowClass.setBackgroundColor(color); -promise.then((data)=> { - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); +let promise = windowClass.resetSize(500, 1000); +promise.then(()=> { + console.info('Succeeded in changing the window size.'); }).catch((err)=>{ - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowBackgroundColor9+ +### setWindowType(deprecated) -setWindowBackgroundColor(color: string): void +setWindowType(type: WindowType, callback: AsyncCallback<void>): void -设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 +设置窗口类型,使用callback异步回调。 + +**系统接口:** 此接口为系统接口。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ------ | -- | ----------------------------------------------------------------------- | -| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let color = '#00ff33'; -try { - windowClass.setWindowBackgroundColor(color); -} catch (exception) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); -}; +let type = window.WindowType.TYPE_APP; +windowClass.setWindowType(type, (err) => { + if (err.code) { + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window type.'); +}); ``` -### setBrightness(deprecated) +### setWindowType(deprecated) -setBrightness(brightness: number, callback: AsyncCallback<void>): void +setWindowType(type: WindowType): Promise<void> -设置屏幕亮度值,使用callback异步回调。 +设置窗口类型,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | ---- | ------------------------------------ | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------- | ---- | ---------- | +| type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let brightness = 1; -windowClass.setBrightness(brightness, (err, data) => { - if (err.code) { - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); +let type = window.WindowType.TYPE_APP; +let promise = windowClass.setWindowType(type); +promise.then(()=> { + console.info('Succeeded in setting the window type.'); +}).catch((err)=>{ + console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); }); ``` -### setBrightness(deprecated) +### getProperties(deprecated) -setBrightness(brightness: number): Promise<void> +getProperties(callback: AsyncCallback<WindowProperties>): void -设置屏幕亮度值,使用Promise异步回调。 +获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。 +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | ---- | ------------------------------------ | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调函数。返回当前窗口属性。 | + +**示例:** + +```js +windowClass.getProperties((err, data) => { + if (err.code) { + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); +}); +``` + +### getProperties(deprecated) + +getProperties(): Promise<WindowProperties> + +获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------------------------------------- | ------------------------------- | +| Promise<[WindowProperties](#windowproperties)> | Promise对象。返回当前窗口属性。 | **示例:** ```js -let brightness = 1; -let promise = windowClass.setBrightness(brightness); +let promise = windowClass.getProperties(); promise.then((data)=> { - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); + console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowBrightness9+ +### getAvoidArea(deprecated) -setWindowBrightness(brightness: number, callback: AsyncCallback<void>): void +getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback<[AvoidArea](#avoidarea7)>): void -设置屏幕亮度值,使用callback异步回调。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------------------------- | -- | --------------------------------- | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |-----------------------------------------------| ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | +| callback | AsyncCallback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回窗口内容规避区域。 | **示例:** ```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)); -}; +let type = window.AvoidAreaType.TYPE_SYSTEM; +windowClass.getAvoidArea(type, (err, data) => { + if (err.code) { + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +}); ``` -### setWindowBrightness9+ +### getAvoidArea(deprecated) -setWindowBrightness(brightness: number): Promise<void> +getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise<[AvoidArea](#avoidarea7)> -设置屏幕亮度值,使用Promise异步回调。 +获取窗口内容规避的区域,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------- | ------ | -- | --------------------------------- | -| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ |----------------------------------| ---- | ------------------------------------------------------------ | +| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------ | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +|-----------------------------------------| ----------------------------------- | +| Promise<[AvoidArea](#avoidarea7)> | 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)); -}; +let type = window.AvoidAreaType.TYPE_SYSTEM; +let promise = windowClass.getAvoidArea(type); +promise.then((data)=> { + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); +}); ``` -### setDimBehind(deprecated) +### setFullScreen(deprecated) -setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void +setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void -窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。 +设置是否为全屏状态,使用callback异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ---- | -------------------------------------------------- | -| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | 是 | 是否设为全屏状态(该全屏状态隐藏状态栏导航栏)。true表示全屏;false表示非全屏。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.setDimBehind(0.5, (err, data) => { +let isFullScreen = true; +windowClass.setFullScreen(isFullScreen, (err) => { if (err.code) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); + console.info('Succeeded in enabling the full-screen mode.'); }); ``` -### setDimBehind(deprecated) +### setFullScreen(deprecated) -setDimBehind(dimBehindValue: number): Promise<void> +setFullScreen(isFullScreen: boolean): Promise<void> -窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。 +设置是否为全屏状态,使用Promise异步回调。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------ | ---- | -------------------------------------------------- | -| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------- | ---- | ---------------------------------------------- | +| isFullScreen | boolean | 是 | 是否设为全屏状态(该全屏状态隐藏状态栏导航栏)。true表示全屏;false表示非全屏。 | **返回值:** @@ -4031,61 +4706,64 @@ setDimBehind(dimBehindValue: number): Promise<void> **示例:** ```js -let promise = windowClass.setDimBehind(0.5); -promise.then((data)=> { - console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)); +let isFullScreen = true; +let promise = windowClass.setFullScreen(isFullScreen); +promise.then(()=> { + console.info('Succeeded in enabling the full-screen mode.'); }).catch((err)=>{ - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); }); ``` -### setFocusable(deprecated) +### setLayoutFullScreen(deprecated) -setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void +setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -设置点击时是否支持切换焦点窗口,使用callback异步回调。 +设置窗口的布局是否为全屏显示状态,使用callback异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | ---------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏;false表示非全屏。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let isFocusable= true; -windowClass.setFocusable(isFocusable, (err, data) => { +let isLayoutFullScreen= true; +windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => { if (err.code) { - console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the window layout to full-screen mode.'); }); ``` -### setFocusable(deprecated) +### setLayoutFullScreen(deprecated) -setFocusable(isFocusable: boolean): Promise<void> +setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> -设置点击时是否支持切换焦点窗口,使用Promise异步回调。 +设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。 +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | ---------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态(该全屏状态下状态栏、导航栏仍然显示)。true表示全屏;false表示非全屏。 | **返回值:** @@ -4096,130 +4774,143 @@ setFocusable(isFocusable: boolean): Promise<void> **示例:** ```js -let isFocusable= true; -let promise = windowClass.setFocusable(isFocusable); -promise.then((data)=> { - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); +let isLayoutFullScreen = true; +let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); +promise.then(()=> { + console.info('Succeeded in setting the window layout to full-screen mode.'); }).catch((err)=>{ - console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); }); ``` -### setWindowFocusable9+ +### setSystemBarEnable(deprecated) -setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void +setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void -设置点击时是否支持切换焦点窗口,使用callback异步回调。 +设置导航栏、状态栏的可见模式,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | -- | -------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | +| 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)); -}; +// 此处以不显示导航栏、状态栏为例 +let names = []; +windowClass.setSystemBarEnable(names, (err) => { + 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.'); +}); ``` -### setWindowFocusable9+ +### setSystemBarEnable(deprecated) -setWindowFocusable(isFocusable: boolean): Promise<void> +setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> -设置点击时是否支持切换焦点窗口,使用Promise异步回调。 +设置导航栏、状态栏的可见模式,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | -- | -------------------------- | -| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----- | ---- | ------------------------------------------------------------ | +| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------ | +| 类型 | 说明 | +| ------------------- | ------------------------- | | 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)); -}; +// 此处以不显示导航栏、状态栏为例 +let names = []; +let promise = windowClass.setSystemBarEnable(names); +promise.then(()=> { + console.info('Succeeded in setting the system bar to be invisible.'); +}).catch((err)=>{ + console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); +}); ``` -### setKeepScreenOn(deprecated) +### setSystemBarProperties(deprecated) -setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void +setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void -设置屏幕是否为常亮状态,使用callback异步回调。 +设置窗口内导航栏、状态栏的属性,使用callback异步回调。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。 +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let isKeepScreenOn = true; -windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +windowClass.setSystemBarProperties(SystemBarProperties, (err) => { if (err.code) { - console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the system bar properties.'); }); ``` -### setKeepScreenOn(deprecated) +### setSystemBarProperties(deprecated) -setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> +setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<void> -设置屏幕是否为常亮状态,使用Promise异步回调。 +设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 > **说明:** -> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。 +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------- | ---- | ------------------------ | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 | **返回值:** @@ -4230,519 +4921,502 @@ setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> **示例:** ```js -let isKeepScreenOn = true; -let promise = windowClass.setKeepScreenOn(isKeepScreenOn); -promise.then((data) => { - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); +let SystemBarProperties={ + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7开始支持 + isStatusBarLightIcon: true, + isNavigationBarLightIcon:false, + //以下两个属性从API Version8开始支持 + statusBarContentColor:'#ffffff', + navigationBarContentColor:'#00ffff' +}; +let promise = windowClass.setSystemBarProperties(SystemBarProperties); +promise.then(()=> { + console.info('Succeeded in setting the system bar properties.'); }).catch((err)=>{ - console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowKeepScreenOn9+ +### loadContent(deprecated) -setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void +loadContent(path: string, callback: AsyncCallback<void>): void -设置屏幕是否为常亮状态,使用callback异步回调。 +为当前窗口加载具体页面内容,使用callback异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------------------------- | -- | ---------------------- | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | +| 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)); -}; +windowClass.loadContent('pages/page2/page2', (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); +}); ``` -### setWindowKeepScreenOn9+ +### loadContent(deprecated) -setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise<void> +loadContent(path: string): Promise<void> -设置屏幕是否为常亮状态,使用Promise异步回调。 +为当前窗口加载具体页面内容,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------- | ------- | -- | ---------------------- | -| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------- | +| path | string | 是 | 设置加载页面的路径。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------ | +| 类型 | 说明 | +| ------------------- | ------------------------- | | 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)); -}; +let promise = windowClass.loadContent('pages/page2/page2'); +promise.then(()=> { + console.info('Succeeded in loading the content.'); +}).catch((err)=>{ + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); +}); ``` -### setWakeUpScreen()9+ +### isShowing(deprecated) -setWakeUpScreen(wakeUp: boolean): void; +isShowing(callback: AsyncCallback<boolean>): void -窗口唤醒屏幕。 +判断当前窗口是否已显示,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ------- | ---- | ---------------------------- | -| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 | **示例:** ```js -let wakeUp = true; -try { - windowClass.setWakeUpScreen(wakeUp); -} catch (exception) { - console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); -}; +windowClass.isShowing((err, data) => { + if (err.code) { + console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); +}); +``` + +### isShowing(deprecated) + +isShowing(): Promise<boolean> + +判断当前窗口是否已显示,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口已显示,返回false表示当前窗口未显示。 | + +**示例:** + +```js +let promise = windowClass.isShowing(); +promise.then((data)=> { + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); +}); ``` -### setOutsideTouchable(deprecated) +### on('systemAvoidAreaChange')(deprecated) -setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void +on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void -设置是否允许可点击子窗口之外的区域,使用callback异步回调。 +开启系统规避区变化的监听。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从API Version 7开始支持。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[on('avoidAreaChange')](#onavoidareachange9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------------------------- | ---- | ---------------- | -| touchable | boolean | 是 | 设置是否可点击。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<[AvoidArea](#avoidarea7)> | 是 | 回调函数。返回当前规避区。 | **示例:** ```js -windowClass.setOutsideTouchable(true, (err, data) => { - if (err.code) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); -}) +windowClass.on('systemAvoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); +}); ``` -### setOutsideTouchable(deprecated) +### off('systemAvoidAreaChange')(deprecated) -setOutsideTouchable(touchable: boolean): Promise<void> +off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void -设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。 +关闭系统规避区变化的监听。 -> **说明:** 该接口不支持使用。 -> -> 从API version 9开始废弃。从 API version 7开始支持。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[off('avoidAreaChange')](#offavoidareachange9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | ------- | ---- | ---------------- | -| touchable | boolean | 是 | 设置是否可点击。 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- |------------------------------------------| ---- | ------------------------------------------------------- | +| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统规避区变化事件。 | +| callback | Callback<[AvoidArea](#avoidarea7)> | 否 | 回调函数。返回当前规避区。 | **示例:** ```js -let promise = windowClass.setOutsideTouchable(true); -promise.then((data)=> { - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)); -}).catch((err)=>{ - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); -}); +windowClass.off('systemAvoidAreaChange'); ``` -### setPrivacyMode(deprecated) +### isSupportWideGamut(deprecated) -setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void +isSupportWideGamut(callback: AsyncCallback<boolean>): void -设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +判断当前窗口是否支持广色域模式,使用callback异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。 +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------------------------- | ---- | -------------------- | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | **示例:** ```js -let isPrivacyMode = true; -windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { +windowClass.isSupportWideGamut((err, data) => { if (err.code) { - console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); - -}); + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); +}) ``` -### setPrivacyMode(deprecated) +### isSupportWideGamut(deprecated) -setPrivacyMode(isPrivacyMode: boolean): Promise<void> +isSupportWideGamut(): Promise<boolean> -设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +判断当前窗口是否支持广色域模式,使用Promise异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。 +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | ---- | -------------------- | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | - **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示当前窗口支持广色域模式,返回false表示当前窗口不支持广色域模式。 | **示例:** ```js -let isPrivacyMode = true; -let promise = windowClass.setPrivacyMode(isPrivacyMode); +let promise = windowClass.isSupportWideGamut(); promise.then((data)=> { - console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)); + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowPrivacyMode9+ +### setColorSpace(deprecated) -setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void +setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void -设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------------------------- | -- | ------------------ | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------ | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -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)); -}; +windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { + if (err.code) { + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting window colorspace.'); +}) ``` -### setWindowPrivacyMode9+ +### setColorSpace(deprecated) -setWindowPrivacyMode(isPrivacyMode: boolean): Promise<void> +setColorSpace(colorSpace:ColorSpace): Promise<void> -设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 +设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 + +> **说明:** +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | -- | ------------------ | -| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 | **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------ | +| 类型 | 说明 | +| ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -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)); -}; -``` - -### setSnapshotSkip9+ -setSnapshotSkip(isSkip: boolean): void - -截屏录屏是否忽略当前窗口。 - -**系统接口:** 此接口为系统接口。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | ------- | ---- | -------------------- | -| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。
true表示忽略当前窗口,false表示不忽略当前窗口。
| - -```js -let isSkip = true; -try { - windowClass.setSnapshotSkip(isSkip); -} catch (exception) { - console.error('Failed to Skip. Cause: ' + JSON.stringify(exception)); -}; +let promise = windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT); +promise.then(()=> { + console.info('Succeeded in setting window colorspace.'); +}).catch((err)=>{ + console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err)); +}); ``` -### setTouchable(deprecated) +### getColorSpace(deprecated) -setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void +getColorSpace(callback: AsyncCallback<ColorSpace>): void -设置窗口是否为可触状态,使用callback异步回调。 +获取当前窗口色域模式,使用callback异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。 +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ---------------------------------------------------------- | +| callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数。当获取成功,err为undefined,data为当前色域模式。 | **示例:** ```js -let isTouchable = true; -windowClass.setTouchable(isTouchable, (err, data) => { +windowClass.getColorSpace((err, data) => { if (err.code) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); - -}); + console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); +}) ``` -### setTouchable(deprecated) +### getColorSpace(deprecated) -setTouchable(isTouchable: boolean): Promise<void> +getColorSpace(): Promise<ColorSpace> -设置窗口是否为可触状态,使用Promise异步回调。 +获取当前窗口色域模式,使用Promise异步回调。 > **说明:** -> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。 +> +> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | - **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| 类型 | 说明 | +| ---------------------------------------- | ------------------------------- | +| Promise<[ColorSpace](#colorspace)> | Promise对象。返回当前色域模式。 | **示例:** ```js -let isTouchable = true; -let promise = windowClass.setTouchable(isTouchable); +let promise = windowClass.getColorSpace(); promise.then((data)=> { - console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)); }).catch((err)=>{ - console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + console.error('Failed to get window colorspace. Cause: ' + JSON.stringify(err)); }); ``` -### setWindowTouchable9+ +### setBackgroundColor(deprecated) -setWindowTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void +setBackgroundColor(color: string, callback: AsyncCallback<void>): void -设置窗口是否为可触状态,使用callback异步回调。 +设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)或[setUIContent()](#setuicontent9)之后使用。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | -- | ------------------ | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -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)); -}; + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let color = '#00ff33'; +windowClass.setBackgroundColor(color, (err) => { + if (err.code) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the background color.'); +}); ``` -### setWindowTouchable9+ +### setBackgroundColor(deprecated) -setWindowTouchable(isTouchable: boolean): Promise<void> +setBackgroundColor(color: string): Promise<void> -设置窗口是否为可触状态,使用Promise异步回调。 +设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)或[setUIContent()](#setuicontent9)之后使用。 + +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | -- | ------------------- | -| isTouchable | boolean | 是 | 窗口是否为可触状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -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)); -}; +let color = '#00ff33'; +let promise = windowClass.setBackgroundColor(color); +promise.then(()=> { + console.info('Succeeded in setting the background color.'); +}).catch((err)=>{ + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); +}); ``` -### setForbidSplitMove9+ +### setBrightness(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void +setBrightness(brightness: number, callback: AsyncCallback<void>): void -设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。 +设置屏幕亮度值,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------ | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -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)); -}; +let brightness = 1; +windowClass.setBrightness(brightness, (err) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness.'); +}); ``` -### setForbidSplitMove9+ +### setBrightness(deprecated) -setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> +setBrightness(brightness: number): Promise<void> -设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 +设置屏幕亮度值,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------- | ---- | -------------------- | -| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------ | +| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | **返回值:** @@ -4753,361 +5427,394 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> **示例:** ```js -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)); -}; +let brightness = 1; +let promise = windowClass.setBrightness(brightness); +promise.then(()=> { + console.info('Succeeded in setting the brightness.'); +}).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); +}); ``` -### snapshot9+ +### setDimBehind(deprecated) -snapshot(callback: AsyncCallback<image.PixelMap>): void +setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void -获取窗口截图,使用callback异步回调。 +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback异步回调。 + +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | ------------------------- | ---- | -------------------- | -| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | -------------------------------------------------- | +| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -windowClass.snapshot((err, data) => { +windowClass.setDimBehind(0.5, (err) => { if (err.code) { - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - data.release(); // PixelMap使用完后及时释放内存 + console.info('Succeeded in setting the dimness.'); }); ``` -### snapshot9+ +### setDimBehind(deprecated) -snapshot(): Promise<image.PixelMap> +setDimBehind(dimBehindValue: number): Promise<void> -获取窗口截图,使用Promise异步回调。 +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise异步回调。 + +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------------------------------------- | +| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + **返回值:** | 类型 | 说明 | | ------------------- | ------------------------- | -| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当前窗口截图。 | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let promise = windowClass.snapshot(); -promise.then((pixelMap)=> { - console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); - pixelMap.release(); // PixelMap使用完后及时释放内存 +let promise = windowClass.setDimBehind(0.5); +promise.then(()=> { + console.info('Succeeded in setting the dimness.'); }).catch((err)=>{ - console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); }); ``` -### opacity9+ +### setFocusable(deprecated) -opacity(opacity: number): void +setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void -设置窗口透明度。 +设置点击时是否支持切换焦点窗口,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | --------------------- | -| opacity | number | 是 | 透明度,范围0.0~1.0。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | ---------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -try { - windowClass.opacity(0.5); -} catch (exception) { - console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); -}; +let isFocusable= true; +windowClass.setFocusable(isFocusable, (err) => { + 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.'); +}); ``` -### scale9+ +### setFocusable(deprecated) -scale(scaleOptions: ScaleOptions): void +setFocusable(isFocusable: boolean): Promise<void> -设置窗口缩放参数。 +设置点击时是否支持切换焦点窗口,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------------ | ---- | ---------- | -| scaleOptions | [ScaleOptions](#scaleoptions9) | 是 | 缩放参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | ---------------------------- | +| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let obj : window.ScaleOptions = { - x : 2.0, - y : 1.0, - pivotX = 0.5; - pivotY = 0.5; -} -try { - windowClass.scale(obj); -} catch (exception) { - console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); -}; +let isFocusable= true; +let promise = windowClass.setFocusable(isFocusable); +promise.then(()=> { + console.info('Succeeded in setting the window to be focusable.'); +}).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); +}); ``` -### rotate9+ +### setKeepScreenOn(deprecated) -rotate(rotateOptions: RotateOptions): void +setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void -设置窗口旋转参数。 +设置屏幕是否为常亮状态,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------------- | -------------------------------- | ---- | ---------- | -| rotateOptions | [RotateOptions](#rotateoptions9) | 是 | 旋转参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let obj : window.RotateOptions = { - x : 1.0, - y : 1.0, - z : 45.0, - pivotX = 0.5; - pivotY = 0.5; -} -try { - windowClass.rotate(obj); -} catch (exception) { - console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); -}; +let isKeepScreenOn = true; +windowClass.setKeepScreenOn(isKeepScreenOn, (err) => { + 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.'); +}); ``` -### translate9+ +### setKeepScreenOn(deprecated) -translate(translateOptions: TranslateOptions): void +setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> -设置窗口平移参数。 +设置屏幕是否为常亮状态,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**参数:** +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------- | ---- | ------------------------ | +| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。true表示常亮;false表示不常亮。 | + +**返回值:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | -------------------------------------- | ---- | ---------- | -| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -let obj : window.TranslateOptions = { - x : 100.0, - y : 0.0, - z : 0.0 -} -try { - windowClass.translate(obj); -} catch (exception) { - console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); -}; +let isKeepScreenOn = true; +let promise = windowClass.setKeepScreenOn(isKeepScreenOn); +promise.then(() => { + console.info('Succeeded in setting the screen to be always on.'); +}).catch((err)=>{ + console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); +}); ``` -### getTransitionController9+ +### setOutsideTouchable(deprecated) - getTransitionController(): TransitionController +setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void -获取窗口属性转换控制器。 +设置是否允许可点击子窗口之外的区域,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -**返回值:** +**参数:** -| 类型 | 说明 | -| ---------------------------------------------- | ---------------- | -| [TransitionController](#transitioncontroller9) | 属性转换控制器。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ---------------- | +| touchable | boolean | 是 | 设置是否可点击。true表示可点击;false表示不可点击。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -let controller = windowClass.getTransitionController(); // 获取属性转换控制器 -controller.animationForHidden = (context : window.TransitionContext) => { - let toWindow = context.toWindow - animateTo({ - duration: 1000, // 动画时长 - tempo: 0.5, // 播放速率 - curve: Curve.EaseInOut, // 动画曲线 - delay: 0, // 动画延迟 - iterations: 1, // 播放次数 - playMode: PlayMode.Normal, // 动画模式 - onFinish: ()=> { - context.completeTransition(true) - } - }, () => { - let obj : window.TranslateOptions = { - x : 100.0, - y : 0.0, - z : 0.0 - } - toWindow.translate(obj); // 设置动画过程中的属性转换 - console.info('toWindow translate end'); - } - ) - console.info('complete transition end'); -} -windowClass.hideWithAnimation((err, data) => { +windowClass.setOutsideTouchable(true, (err) => { if (err.code) { - console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); + console.info('Succeeded in setting the area to be touchable.'); }) ``` -### setBlur9+ +### setOutsideTouchable(deprecated) -setBlur(radius: number): void +setOutsideTouchable(touchable: boolean): Promise<void> -设置窗口模糊。 +设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 该接口不支持使用。从 API version 7开始支持,从API version 9开始废弃。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------- | ---- | ---------------- | +| touchable | boolean | 是 | 设置是否可点击。true表示可点击;false表示不可点击。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -try { - windowClass.setBlur(4.0); -} catch (exception) { - console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); -}; +let promise = windowClass.setOutsideTouchable(true); +promise.then(()=> { + console.info('Succeeded in setting the area to be touchable.'); +}).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); +}); ``` -### setBackdropBlur9+ +### setPrivacyMode(deprecated) -setBackdropBlur(radius: number): void +setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -设置窗口背景模糊。 +设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------------------------- | ---- | -------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -try { - windowClass.setBackdropBlur(4.0); -} catch (exception) { - console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); -}; +let isPrivacyMode = true; +windowClass.setPrivacyMode(isPrivacyMode, (err) => { + 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.'); + +}); ``` -### setBackdropBlurStyle9+ +### setPrivacyMode(deprecated) -setBackdropBlurStyle(blurStyle: BlurStyle): void +setPrivacyMode(isPrivacyMode: boolean): Promise<void> -设置窗口背景模糊类型。 +设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | --------- | ---- | ---------------------- | -| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -try { - windowClass.setBackdropBlurStyle(window.BlurType.THIN); -} catch (exception) { - console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); -}; +let isPrivacyMode = true; +let promise = windowClass.setPrivacyMode(isPrivacyMode); +promise.then(()=> { + console.info('Succeeded in setting the window to privacy mode.'); +}).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); +}); ``` -### setShadow9+ +### setTouchable(deprecated) -setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void -设置窗口边缘阴影。 +设置窗口是否为可触状态,使用callback异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------------------------ | -| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | -| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 | -| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 | -| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | **示例:** ```js -try { - windowClass.setShadow(4.0, '#FF00FF00', 2, 3); -} catch (exception) { - console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); -}; +let isTouchable = true; +windowClass.setTouchable(isTouchable, (err) => { + 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.'); + +}); ``` -### setCornerRadius9+ +### setTouchable(deprecated) -setCornerRadius(cornerRadius: number): void +setTouchable(isTouchable: boolean): Promise<void> -设置窗口圆角半径。 +设置窗口是否为可触状态,使用Promise异步回调。 -**系统接口:** 此接口为系统接口。 +> **说明:** +> +> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -5115,16 +5822,24 @@ setCornerRadius(cornerRadius: number): void | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------- | ---- | -------------------- | -| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | +| isTouchable | boolean | 是 | 窗口是否为可触状态。true表示可触;false表示不可触。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | **示例:** ```js -try { - windowClass.setCornerRadius(4.0); -} catch (exception) { - console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); -}; +let isTouchable = true; +let promise = windowClass.setTouchable(isTouchable); +promise.then(()=> { + console.info('Succeeded in setting the window to be touchable.'); +}).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); +}); ``` ## WindowStageEventType9+ @@ -5164,6 +5879,15 @@ getMainWindow(callback: AsyncCallback<Window>): void | -------- | -------------------------------------- | ---- | --------------------------------------------- | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的主窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5200,6 +5924,15 @@ getMainWindow(): Promise<Window> | -------------------------------- | ------------------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的主窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5221,7 +5954,7 @@ class myAbility extends Ability { ### getMainWindowSync9+ -getMainWindow(): Window; +getMainWindowSync(): Window 获取该WindowStage实例下的主窗口。 @@ -5235,6 +5968,15 @@ getMainWindow(): Window; | ----------------- | --------------------------------- | | [Window](#window) | 返回当前WindowStage下的主窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5268,6 +6010,15 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void | name | String | 是 | 子窗口的名字。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5314,6 +6065,15 @@ createSubWindow(name: string): Promise<Window> | -------------------------------- | ------------------------------------------------ | | Promise<[Window](#window)> | Promise对象。返回当前WindowStage下的子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5353,6 +6113,14 @@ getSubWindow(callback: AsyncCallback<Array<Window>>): void | -------- | --------------------------------------------------- | ---- | ------------------------------------------------- | | callback | AsyncCallback<Array<[Window](#window)>> | 是 | 回调函数。返回当前WindowStage下的所有子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5388,6 +6156,14 @@ getSubWindow(): Promise<Array<Window>> | --------------------------------------------- | ---------------------------------------------------- | | Promise<Array<[Window](#window)>> | Promise对象。返回当前WindowStage下的所有子窗口对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5424,6 +6200,15 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void | storage | [LocalStorage](../../ui/ui-ts-local-storage.md) | 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5435,12 +6220,12 @@ class myAbility extends Ability { this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); try { - windowStage.loadContent('pages/page2',this.storage,(err, data) => { + windowStage.loadContent('pages/page2',this.storage,(err) => { 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)); + console.info('Succeeded in loading the content.'); }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); @@ -5472,6 +6257,15 @@ loadContent(path: string, storage?: LocalStorage): Promise<void> | ------------------- | ------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5482,12 +6276,10 @@ class myAbility extends Ability { this.storage = new LocalStorage(); this.storage.setOrCreate('storageSimpleProp',121); console.log('onWindowStageCreate'); - let windowClass = null; 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)); + promise.then(()=> { + console.info('Succeeded in loading the content.'); }).catch((err)=>{ console.error('Failed to load the content. Cause:' + JSON.stringify(err)); }); @@ -5515,6 +6307,15 @@ loadContent(path: string, callback: AsyncCallback<void>): void | path | string | 是 | 设置加载页面的路径。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5523,12 +6324,12 @@ class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); try { - windowStage.loadContent('pages/page2', (err, data) => { + windowStage.loadContent('pages/page2', (err) => { 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)); + console.info('Succeeded in loading the content.'); }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); @@ -5554,6 +6355,15 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType> | type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 | | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 是 | 回调函数。返回当前的WindowStage生命周期状态。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5591,6 +6401,15 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g | type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 | | callback | Callback<[WindowStageEventType](#windowstageeventtype9)> | 否 | 回调函数。返回当前的WindowStage生命周期状态。 | +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5620,6 +6439,15 @@ disableWindowDecor(): void **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | + **示例:** ```ts @@ -5648,7 +6476,16 @@ setShowOnLockScreen(showOnLockScreen: boolean): void | 参数名 | 类型 | 必填 | 说明 | | ---------------- | ------- | ---- | ---------------------------- | -| showOnLockScreen | boolean | 是 | 是否设置应用显示在锁屏之上。 | +| showOnLockScreen | boolean | 是 | 是否设置应用显示在锁屏之上。true表示显示在锁屏之上;false表示不显示在锁屏之上。 | + +**错误码:** + +以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300005 | This window stage is abnormal. | **示例:** @@ -5693,7 +6530,7 @@ completeTransition(isCompleted: boolean): void | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------- | ---- | ------------------------------------------------------------ | -| isCompleted | boolean | 是 | 窗口属性转换是否完成。true:完成本次转换;false:撤销本次转换。 | +| isCompleted | boolean | 是 | 窗口属性转换是否完成。true表示完成本次转换;false表示撤销本次转换。 | **示例:** @@ -5821,4 +6658,4 @@ controller.animationForHidden = (context : window.TransitionContext) => { ) console.info('complete transition end'); } -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-display.md b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md new file mode 100755 index 0000000000000000000000000000000000000000..2d19ab659374a9e87095fcb53c883148a3af0ec0 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-display.md @@ -0,0 +1,34 @@ +# 屏幕错误码 + +## 1400001 无效虚拟屏 +### 错误信息 +This is invalid screen. +### 错误描述 +当操作无效的虚拟屏时,会报此错误码。 +### 可能原因 +1. 虚拟屏未创建。 +2. 虚拟屏已销毁。 +### 处理步骤 +1. 在操作虚拟屏前,检查该虚拟屏是否已经存在,确保已创建该虚拟屏。 +2. 在操作虚拟屏前,检查虚拟屏是否已被销毁,确保其未被销毁,再进行相关操作。 + +## 1400002 无权限操作 +### 错误信息 +This operation is not access. +### 错误描述 +当对无操作权限的对象进行操作时,会报此错误码。 +### 可能原因 +操作了其它进程的虚拟屏对象。 +### 处理步骤 +请检查是否非法操作了别的进程的对象,删除相关非法操作。 + +## 1400003 系统服务工作异常 +### 错误信息 +This window manager service work abnormally. +### 错误描述 +当系统服务工作异常时,会报此错误码。 +### 可能原因 +1. 窗口内部服务没有正常启动。 +2. 底层图形图像合成渲染异常。 +### 处理步骤 +系统服务内部工作异常,请稍候重试,或者重启设备尝试。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-window.md b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md new file mode 100755 index 0000000000000000000000000000000000000000..f55c63a902daf8e263d1f9fd410fb70791b8bfef --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-window.md @@ -0,0 +1,61 @@ +# 窗口错误码 + +## 1300001 重复操作 +### 错误信息 +This is repeat operation. +### 错误描述 +当进行某些重复操作时,系统会报此错误码。 +### 可能原因 +创建的窗口已经存在时,再次创建该窗口会报错。 +### 处理步骤 +在创建窗口前,检查该窗口是否已经存在,确保为首次创建该窗口。 + +## 1300002 窗口状态异常 +### 错误信息 +This window state is abnormal. +### 错误描述 +当窗口状态异常,如已被销毁时,操作该窗口,会报此错误码。 +### 可能原因 +操作窗口时,该窗口已被销毁。 +### 处理步骤 +在对窗口进行操作前,检查该窗口是否存在,确保其未被销毁,再进行相关操作。 + +## 1300003 系统服务工作异常 +### 错误信息 +This window manager service work abnormally. +### 错误描述 +当系统服务工作异常时,会报此错误码。 +### 可能原因 +窗口内部服务没有正常启动。 +### 处理步骤 +系统服务内部工作异常,请稍候重试,或者重启设备尝试。 + +## 1300004 无权限操作 +### 错误信息 +This operation is not access. +### 错误描述 +当对无操作权限的对象进行操作时,会报此错误码。 +### 可能原因 +操作了其它进程的窗口对象。 +### 处理步骤 +请检查是否非法操作了别的进程的对象,删除相关操作。 + +## 1300005 WindowStage异常 +### 错误信息 +This window stage is abnormal. +### 错误描述 +当WindowStage异常,如已被销毁时,操作该WindowStage,会报此错误码。 +### 可能原因 +操作WindowStage时,该WindowStage已被销毁。 +### 处理步骤 +在对WindowStage进行操作前,检查该WindowStage是否存在,若已被销毁,请释放该WindowStage下的窗口。 + +## 1300006 窗口上下文异常 +### 错误信息 +This window context is abnormal. +### 错误描述 +当窗口上下文异常,如已被销毁时,操作该窗口上下文,会报此错误码。 +### 可能原因 +操作窗口上下文时,该窗口上下文已被销毁。 +### 处理步骤 +在对窗口上下文进行操作前,检查该窗口上下文是否存在,确保其未被销毁,再进行相关操作。