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 7ceb3a6c4b5c0ed422b81e41d329679df0464c73..502310b2ed05370d203df9bf22bf2a3bc1a67b7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -3,447 +3,456 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 ``` import window from '@ohos.window'; ``` +## WindowType7+ + +窗口类型。 + +| 名称 | 默认值 | 说明 | +| ----------------- | ------ | ------------------------------------------------------------ | +| TYPE_APP | 0 | 表示应用子窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -## 系统能力 -SystemCapability.WindowManager.WindowManager.Core +## AvoidAreaType7+ +窗口内容需要规避区域的类型。 +| 名称 | 默认值 | 说明 | +| ----------- | ------ | ------------------------------------------------------------ | +| TYPE_SYSTEM | 0 | 表示系统默认区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| TYPE_CUTOUT | 1 | 表示刘海屏区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -## 权限列表 +## WindowMode7+ -ohos.permission.SYSTEM_FLOAT_WINDOW +窗口模式。 +| 名称 | 默认值 | 说明 | +| ---------- | ------ | ------------------------------------------------------------ | +| UNDEFINED | 1 | 表示APP未定义窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| FULLSCREEN | 2 | 表示APP全屏模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| PRIMARY | 3 | 表示APP分屏多窗口主要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| SECONDARY | 4 | 表示APP分屏多窗口次要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -## SystemBarProperties +## SystemBarProperties 状态栏导航栏的属性。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| statusBarColor | string | 是 | 是 | 状态栏颜色,为16进制颜色,例如"\#00FF00"或"\#FF00FF00"。 | -| isStatusBarLightIcon7+ | boolean | 是 | 是 | 状态栏图标是否为高亮状态。 | -| navigationBarColor | string | 是 | 是 | 导航栏颜色,为16进制颜色,例如"\#00FF00"或"\#FF00FF00"。 | -| isNavigationBarLightIcon7+ | boolean | 是 | 是 | 导航栏图标是否为高亮状态。 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | +| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | + +## SystemBarRegionTint 8+ + +单个导航栏或状态栏回调信息。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------------------------------------- | ------------------------ | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| contentColor | string | 是 | 是 | 系统栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +## SystemBarTintState 8+ + +当前系统栏回调信息集合。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | -------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| displayId | number | 是 | 否 | 当前物理屏幕id。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | 是 | 是 | 当前改变所有的系统栏信息。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | ## Rect7+ 矩形。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| left | number | 是 | 是 | 矩形区域的左边界。 | -| top | number | 是 | 是 | 矩形区域的上边界。 | -| width | number | 是 | 是 | 矩形区域的宽度。 | -| height | number | 是 | 是 | 矩形区域的高度。 | - +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| left | number | 是 | 是 | 矩形区域的左边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| top | number | 是 | 是 | 矩形区域的上边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| width | number | 是 | 是 | 矩形区域的宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| height | number | 是 | 是 | 矩形区域的高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | ## AvoidArea7+ 表示窗口内容规避区域。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | -| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | -| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | -| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。 | - +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | ------------- | ---- | ---- | ------------------------------------------------------------ | +| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | ## Size7+ 窗口大小。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| width | number | 是 | 是 | 窗口宽度。 | -| height | number | 是 | 是 | 窗口高度。 | - +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| width | number | 是 | 是 | 窗口宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| height | number | 是 | 是 | 窗口高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -## WindowProperties +## WindowProperties 窗口属性。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| windowRect7+ | [Rect](#rect) | 是 | 否 | 窗口尺寸。 | -| type7+ | [WindowType](#windowtype) | 是 | 否 | 窗口类型。 | -| brightness | number | 是 | 是 | 屏幕亮度,取值范围为0~1,1表示最大亮度值。 | -| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明,默认为false。 | -| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | -| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。 | -| dimBehindValue7+ | number | 是 | 是 | 靠后的窗口的暗度值,取值范围为0~1,1表示最暗。 | -| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | -| focusable7+ | boolean | 是 | 是 | 窗口是否可聚焦,默认为true。 | -| touchable7+ | boolean | 是 | 是 | 窗口是否可触摸,默认为true。 | -| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。 | -| isRoundCorner7+ | boolean | 是 | 是 | 窗口是否为圆角。 | - +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | +| windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -## SplitScreenBoundsInfo7+ +## ColorSpace8+ -分屏边界相关信息。 +色域模式。 -| 名称 | 类型 | 说明 | -| -------- | -------- | -------- | -| [splitMode](#splitmode) | number | 表示分屏模式。 | -| primaryBounds | [Rect](#rect) | 表示主要边界信息,返回Rect类实例。 | -| secondaryBounds | [Rect](#rect) | 表示次要边界信息,返回Rect类实例。 | +| 名称 | 默认值 | 说明 | +| ---------- | ------ | ------------------------------------------------------------ | +| DEFAULT | 0 | 默认色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| WIDE_GAMUT | 1 | 广色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +## window.create7 -## window.getTopWindow +create(id: string, type: WindowType, callback: AsyncCallback<Window>): void -getTopWindow(callback: AsyncCallback<Window>): void +创建子窗口。 -获取当前窗口,用于获取到window实例。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | -------------------------- | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回创建的子窗口对象。 | - 示例 - ``` - window.getTopWindow((err, data) => { - if (err) { - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); - windowClass = data; - }); - ``` +``` + window.create("first", 1, (err, data) => { + windowClass = data; + if (err) { + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('SubWindow created. Data: ' + JSON.stringify(data)) + windowClass.resetSize(500, 1000); +}) +``` + +## window.create8+ -## window.create7+ +create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void -create(id: string, type: WindowType, callback: AsyncCallback<Window>): void +当Context为[ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md)时,创建系统窗口。 -创建子窗口。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | id | string | 是 | 窗口id。 | - | type | [WindowType](#windowtype) | 是 | 窗口类型。 | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | -- 示例 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息, 为ServiceExtensionContext的基类。 | + | id | string | 是 | 窗口id。 | + | type | [WindowType](#windowtype) | 是 | 窗口类型。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | +- 示例 ``` - window.create("first", 1, (err, data) => { + #this.context为 + window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { windowClass = data; if (err) { - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); return; } - console.info('SubWindow created. Data: ' + JSON.stringify(data)) + console.info('Window created. Data: ' + JSON.stringify(data)) windowClass.resetSize(500, 1000); - windowClass.setOutsideTouchable(true); - windowClass.loadContent("pages/index/index", (err, data) => { - }); }) ``` - -## window.find7+ +## window.find7+ find(id: string, callback: AsyncCallback<Window>): void -查找子窗口。 +查找id所对应的窗口。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | id | string | 是 | 窗口id。 | - | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前窗口对象。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | ---------------------------- | + | id | string | 是 | 窗口id。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前查找的窗口对象。 | - 示例 + ``` window.find("first", (err, data) => { if (err) { - console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err)); + console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); return; } - console.info('SubWindow found. Data: ' + JSON.stringify(data)) + console.info('window found. Data: ' + JSON.stringify(data)) windowClass = data; }) ``` +## window.getTopWindow -## window.getAbilityWindowMode7+ +getTopWindow(callback: AsyncCallback<Window>): void -getAbilityWindowMode(callback: AsyncCallback<WindowMode>): void +获取当前应用内最后显示的窗口。 -获取当前窗口模式。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WindowMode](#windowmode)> | 是 | 回调返回当前窗口模式。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------- | ---- | -------------------------------------- | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 | - 示例 + ``` - window.getAbilityWindowMode((err, data) => { + window.getTopWindow((err, data) => { if (err) { - console.error('Failed to obtain the window mode. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Window mode obtained. Data:' + JSON.stringify(data)) - + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + windowClass = data; }); ``` +## window.getTopWindow8+ -## window.getSplitScreenBounds7+ +getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void -getSplitScreenBounds(splitRatio: SplitRatio, callback: AsyncCallback<SplitScreenBoundsInfo>): void +获取当前应用内最后显示的窗口。 -获取分屏多窗口的位置和区域.。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | splitRatio | SplitRatio | 是 | 表示分屏比例,默认值为1:1,传值1表示1:2,传值2为2:1。 | - | callback | AsyncCallback<[SplitScreenBoundsInfo](#splitscreenboundsinfo)> | 是 | 回调返回一个SplitScreenBoundsInfo对象,表示分屏边界相关信息。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | + | ctx | [Context](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md) | 是 | 当前应用上下文信息。 | + | callback | AsyncCallback<[Window](#window)> | 是 | 回调返回当前应用内最后显示的窗口对象。 | - 示例 + ``` - var splitRatio = '1:1'; - window.getSplitScreenBounds(splitRatio, (err, data) => { + window.getTopWindow(this.context, (err, data) => { if (err) { - console.error('Failed to obtain the split-screen boundary information. Cause: ' + JSON.stringify(err)); + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Split-screen boundary information obtained. Data: ' + JSON.stringify(data)) - + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); + windowClass = data; }); ``` +## on('systemBarTintChange')8+ -## window.isFloatingAbilityWindowVisible7+ +on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void -isFloatingAbilityWindowVisible(callback:AsyncCallback<boolean>): void +注册状态栏、导航栏的监听函数。 -悬浮窗是否显示可见。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调返回一个boolean对象,表示悬浮窗是否可见。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'systemBarTintChange'时表示监听类型为导航栏、状态栏属性变化监听; | + | callback | Callback<[SystemBarTintState](#systembartintstate)> | 是 | 回调返回监听到的信息。 | - 示例 + ``` - window.isFloatingAbilityWindowVisible( (err, data) => { - if (err) { - console.error('Failed to check whether the floating window is visible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the floating window is visible. Data:' + JSON.stringify(data)) - + var type = 'systemBarTintChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); }); ``` +## off('systemBarTintChange')8+ -## window.setSplitBarVisibility7+ +off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void -setSplitBarVisibility(isVisibility: boolean, callback: AsyncCallback<void>): void +关闭监听。 -设置分屏线是否可见。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | isVisibility | boolean | 表示分屏线是否是否显示,true为显示,false为显示。 | - | callback | AsyncCallback<void> | callback形式返回结果。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'systemBarTintChange'时表示监听类型为导航栏、状态栏属性变化监听; | + | callback | Callback<[SystemBarTintState](#systembartintstate)> | 否 | 回调返回监听到的信息。 | - 示例 + ``` - var isVisibility = false; - window.setSplitBarVisibility(isVisibility , (err, data) => { - if (err) { - console.error('Failed to set the divider to be invisible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the divider to be invisible. Data:' + JSON.stringify(data)) - }); + var type = 'systemBarTintChange'; + windowClass.off(type); ``` - -## WindowType7+ - -窗口类型。 - -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| TYPE_APP | 0 | 表示应用窗口。 | -| TYPE_SYSTEM_ALERT | 1 | 表示系统弹窗。 | - - -## AvoidAreaType7+ - -窗口内容需要规避区域的类型。 - -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| TYPE_SYSTEM | 0 | 表示系统默认。 | -| TYPE_CUTOUT | 1 | 表示刘海屏区域。 | - - -## WindowMode7+ - -窗口模式。 - -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| UNDEFINED | 1 | 表示APP未定义窗口模式。 | -| FULLSCREEN | 2 | 表示APP全屏模式。 | -| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 | -| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 | -| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 | - - -## splitMode7+ - -分屏模式。 - -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| VERTICAL | 0 | 表示垂直上下分屏模式 | -| HORIZONTAL | 1 | 表示水平左右分屏模式 | - - ## Window -下列API示例中都需使用[getTopWindow()](#window-gettopwindow)先获取到Window实例,再通过此实例调用对应方法。 +下列API示例中都需使用[getTopWindow()](#window-gettopwindow)、[create()](#window-create)、[find()](#window-find)等先获取到Window实例,再通过此实例调用对应方法。 +### hide7+ -### setBrightness +hide (callback: AsyncCallback<void>): void -setBrightness(brightness:number, callback: AsyncCallback<void>): void +隐藏当前窗口。 -设置屏幕亮度值。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------- | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var brightness = 10; - windowClass.setBrightness(brightness, (err, data) => { + windowClass.hide((err, data) => { if (err) { - console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); - }); + console.info('window hidden. Data:' + JSON.stringify(data)) + }) ``` +### show7+ -### setBackgroundColor +show(callback: AsyncCallback<void>): void -setBackgroundColor(color: string, callback: AsyncCallback<void>): void +显示当前窗口。 -设置窗口的背景色。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | color | string | 是 | 需要设置的背景色,为16进制颜色,例如"\#00FF00"或"\#FF00FF00"。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------- | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var color = '#00ff33'; - windowClass.setBackgroundColor(color, (err, data) => { + windowClass.show((err, data) => { if (err) { - console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); - }); + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) + }) ``` -### setTransparent7+ +### destroy7+ + +destroy(callback: AsyncCallback<void>): void -setTransparent(isTransparent: boolean, callback: AsyncCallback<void>): void +销毁当前窗口。 -设置窗口是否透明。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isTransparent | boolean | 是 | 窗口是否透明。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------- | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var isTransparent = true; - windowClass.setTransparent(isTransparent, (err, data) => { + windowClass.destroy((err, data) => { if (err) { - console.error('Failed to set the window to be transparent. Cause: ' + JSON.stringify(err)); + console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be transparent. Data: ' + JSON.stringify(data)) - }); + console.info('Succeeded in destroying the window. Data:' + JSON.stringify(data)) + }) ``` -### setFullScreen +### moveTo7+ -setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void +moveTo(x: number, y: number, callback: AsyncCallback<void>): void -设置是否为全屏状态。 +移动窗口位置。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isFullScreen | boolean | 是 | 是否设为全屏状态。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | --------------------------------------- | + | x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移。 | + | y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var isFullScreen = true; - windowClass.setFullScreen(isFullScreen, (err, data) => { + windowClass.moveTo(300, 300, (err, data)=>{ if (err) { - console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); + console.info('Window moved. Data:' + JSON.stringify(data)); + }); ``` -### setKeepScreenOn +### resetSize7+ + +resetSize(width: number, height: number, callback: AsyncCallback<void>): void -setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void +改变当前窗口大小。 -设置屏幕是否为常亮状态。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ---------------- | + | width | number | 是 | 目标窗口的宽度。 | + | height | number | 是 | 目标窗口的高度。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var isKeepScreenOn = true; - windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { + windowClass.resetSize(500, 1000, (err, data) => { if (err) { - console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); + console.info('Window size changed. Data:' + JSON.stringify(data)); }); ``` @@ -453,13 +462,17 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void 设置窗口类型。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [WindowType](#windowtype7) | 是 |窗口类型。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------- | ---- | ---------- | + | type | [WindowType](#windowtype7) | 是 | 窗口类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` var type = window.TYPE_APP; windowClass.setWindowType(type, (err, data) => { @@ -471,140 +484,133 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void }); ``` -### setDimBehind7+ - -setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void - -窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例 - ``` - windowClass.setDimBehind(0.5, (err, data) => { - if (err) { - console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); - }); - ``` +### getProperties -### setLayoutFullScreen7+ +getProperties(callback: AsyncCallback<WindowProperties>): void -setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void +获取当前窗口的属性,异步返回WindowProperties。 -设置窗口的布局是否为全屏显示状态。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------------------------- | ---- | ------------------ | + | callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调返回窗口属性。 | - 示例 + ``` - var isLayoutFullScreen= true; - windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + windowClass.getProperties((err, data) => { if (err) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the window properties. 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 obtaining the window properties. Data: ' + JSON.stringify(data)); }); ``` -### setFocusable7+ +### getAvoidArea7+ -setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void +getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): void -设置点击时是否支持切换焦点窗口。 +获取窗口内容规避的区域。如系统的系统栏区域 、凹口区域。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | + | type | [AvoidAreaType](#avoidareatype) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。 | + | callback | AsyncCallback<[AvoidArea](#avoidarea)> | 是 | 回调返回窗口内容规避区域。 | - 示例 + ``` - var isFocusable= true; - windowClass.setFocusable(isFocusable, (err, data) => { + var type = window.AvoidAreaType.TYPE_SYSTEM; + windowClass.getAvoidArea(type, (err, data) => { if (err) { - console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); + console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); }); ``` -### setTouchable7+ +### setFullScreen + +setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void -setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void +设置是否为全屏状态。 -设置窗口是否为可触状态。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isTouchable | boolean | 是 | 窗口是否为可触状态。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | ------------ | ------------------------- | ---- | ---------------------------------------------- | + | isFullScreen | boolean | 是 | 是否设为全屏状态,且全屏状态隐藏状态栏导航栏。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var isTouchable = true; - windowClass.setTouchable(isTouchable, (err, data) => { + var isFullScreen = true; + windowClass.setFullScreen(isFullScreen, (err, data) => { if (err) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); - + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); }); ``` -### setPrivacyMode7+ +### setLayoutFullScreen7+ + +setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void -setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void +设置窗口的布局是否为全屏显示状态。 -设置窗口是否为隐私模式。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------ | ------------------------- | ---- | ------------------------------------------------------------ | +| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - var isPrivacyMode = true; - windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { + var isLayoutFullScreen= true; + windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err) { - console.error('Failed to set the window to privacy mode. 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 privacy mode. Data:' + JSON.stringify(data)); - + console.info('Succeeded in setting the window layout to full-screen mode. Data:' + JSON.stringify(data)); }); ``` ### setSystemBarEnable7+ -setSystemBarEnable(names: Array, callback: AsyncCallback<void>): void +setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void 设置导航栏、状态栏的可见模式。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | names | Array | 是 | 设置状态栏和导航栏是否显示。例如,需全部显示,该参数设置为["status", "navigation"]。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------------------------------------------------------ | + | names | Array | 是 | 设置状态栏和导航栏是否显示。例如,需全部显示,该参数设置为["status", "navigation"], 不设置,则默认不显示。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` var names = ["status", "navigation"]; windowClass.setSystemBarEnable(names, (err, data) => { @@ -620,15 +626,19 @@ setSystemBarEnable(names: Array, callback: AsyncCallback<void>): void setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void -设置窗口内导航条状态栏的属性。 +设置窗口内导航栏、状态栏的属性。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航条状态栏的属性。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | ------------------- | ------------------------------------------- | ---- | -------------------- | + | SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏状态栏的属性。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` var SystemBarProperties={ statusBarColor: '#ff00ff', @@ -646,114 +656,24 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async }); ``` -### getProperties - -getProperties(callback: AsyncCallback<WindowProperties>): void - -获取当前窗口的属性,异步返回WindowProperties。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WindowProperties](#windowproperties)> | 是 | 回调返回窗口属性。 | - -- 示例 - ``` - windowClass.getProperties((err, data) => { - if (err) { - console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data)); - }); - ``` +### loadContent8+ -### getAvoidArea7+ +loadContent(path: string, callback: AsyncCallback<void>): void -getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): void +当前窗口加载具体页面内容。 -获取窗口内容规避的区域。如系统的系统栏区域 、凹口区域。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | [AvoidAreaType](#avoidareatype) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。 | - | callback | AsyncCallback<[AvoidArea](#avoidarea)> | 是 | 回调返回窗口内容规避区域。 | - -- 示例 - ``` - var type = window.AvoidAreaType.TYPE_SYSTEM; - windowClass.getAvoidArea(type, (err, data) => { - if (err) { - console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in obtaining the area. Data:' + JSON.stringify(data)); - }); - ``` - -### moveTo7+ - -moveTo(x: number, y: number, callback: AsyncCallback<void>): void -窗口位置移动。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移。 | - | y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | -------------------- | + | path | string | 是 | 设置加载页面的路径。| + | storage | ContentStorage | 否 | 当前应用内的数据。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 - ``` - windowClass.moveTo(300, 300, (err, data)=>{ - if (err) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window moved. Data:' + JSON.stringify(data)); - - }); - ``` - -### resetSize7+ - -resetSize(width: number, height: number, callback: AsyncCallback<void>): void - -改变当前窗口大小。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | width | number | 是 | 目标窗口的宽度。 | - | height | number | 是 | 目标窗口的高度。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | -- 示例 - ``` - windowClass.resetSize(500, 1000, (err, data) => { - if (err) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Window size changed. Data:' + JSON.stringify(data)); - }); - ``` - -### loadContent7+ - -loadContent(path: string, callback: AsyncCallback<void>): void - -子窗口加载具体页面内容。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | path | string | 是 | 设置加载页面的代码路径。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | - -- 示例 ``` windowClass.loadContent("pages/page2/page2", (err, data) => { if (err) { @@ -764,199 +684,155 @@ loadContent(path: string, callback: AsyncCallback<void>): void }); ``` -### hide7+ +### isShowing7+ -hide (callback: AsyncCallback<void>): void +isShowing(callback: AsyncCallback<boolean>): void + +判断当前窗口是否已显示。 -隐藏子窗口。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------- | --- | ---------------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数返回是否显示子窗口结果。 | - 示例 + ``` - windowClass.hide((err, data) => { + windowClass.isShowing((err, data) => { if (err) { - console.error('Failed to hide the subwindow. Cause: ' + JSON.stringify(err)); + console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); return; } - console.info('Subwindow hidden. Data:' + JSON.stringify(data)) + console.info('Succeeded in checking whether the window is showing. Cause:' + JSON.stringify(data)) }) ``` -### show7+ +### on('windowSizeChange'|'systemAvoidAreaChange') -show(callback: AsyncCallback<void>): void +on(type: 'windowSizeChange'|'systemAvoidAreaChange', callback: Callback<AvoidArea | Size>): void -显示子窗口。 +开启监听。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size)> | 是 | 回调返回监听到的信息。 | - 示例 + ``` - windowClass.show((err, data) => { - if (err) { - console.error('Failed to show the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the subwindow. Data: ' + JSON.stringify(data)) - }) + var type = 'windowSizeChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); + }); ``` -### isShowing7+ +### off('windowSizeChange'|'systemAvoidAreaChange')7+ -isShowing(callback: AsyncCallback<boolean>): void +off(type: 'windowSizeChange'|'systemAvoidAreaChange', callback?: Callback<AvoidArea | Size >): void -判断子窗口是否已显示。 +关闭监听。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数返回是否显示子窗口结果。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size)> | 否 | 回调返回监听到的信息。 | - 示例 + ``` - windowClass.isShowing((err, data) => { - if (err) { - console.error('Failed to check whether the subwindow is showing. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in checking whether the subwindow is showing. Cause:' + JSON.stringify(data)) - }) + var type = 'windowSizeChange'; + windowClass.off(type); ``` -### destroy7+ +### isSupportWideGamut8+ -destroy(callback: AsyncCallback<void>): void +isSupportWideGamut(callback: AsyncCallback): void + +判断当前窗口是否支持广色域模式。 -销毁子窗口。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------- | ---- | -------------------------------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数返回是否支持广色域模式。 | - 示例 + ``` - windowClass.destroy((err, data) => { + windowClass.isSupportWideGamut((err, data) => { if (err) { - console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err)); + console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in destroying the subwindow. Data:' + JSON.stringify(data)) + console.info('Succeeded in checking whether the window support WideGamut. Cause:' + JSON.stringify(data)) }) ``` -### setOutsideTouchable7+ +### setColorSpace8+ + +setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback): void -setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void; +设置当前窗口为广色域模式或默认色域模式。 -设置是否允许可点击子窗口以外的区域。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | touchable | boolean | 是 | 设置是否可点击。 | - | callback | AsyncCallback<void> | 是 | 回调函数。 | + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------------------------- | ---- | ------------ | + | colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 + ``` - windowClass.setOutsideTouchable(true, (err, data) => { + windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { if (err) { - console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + console.info('Succeeded in setting window colorspace. Cause:' + JSON.stringify(data)) }) ``` -### on('keyboardHeightChange') +### getColorSpace8+ -on(type: string, callback: AsyncCallback<number>): void +getColorSpace(callback: AsyncCallback): void -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从 API Version 7 开始废弃。 +获取当前窗口色域模式。 -开启监听键盘高度变化。 +**系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置监听类型为监听键盘高度变化,应设置type为'keyboardHeightChange'。 | - | callback | AsyncCallback<number> | 是 | 回调返回监听到的键盘高度。 | + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------------------------------- | ---- | -------------------------- | + | callback | AsyncCallback<[ColorSpace](#colorspace)> | 是 | 回调函数返回当前色域模式。 | - 示例 + ``` - var type= 'keyboardHeightChange'; - windowClass.on(type, (err, data) => { + windowClass.getColorSpace((err, data) => { if (err) { - console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(err)); + console.error('Failed to get window color space. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); - }); - ``` - -### off('keyboardHeightChange') - -off(type: string, callback?: AsyncCallback<number>): void - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从 API Version 7 开始废弃。 - -关闭监听键盘高度变化。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置监听类型为监听键盘高度变化,应设置type为'keyboardHeightChange'。 | - | callback | AsyncCallback<number> | 否 | 回调返回监听到的键盘高度。 | - -- 示例 - ``` - var type= 'keyboardHeightChange'; - windowClass.off(type); - ``` - -### on('keyboardHeightChange'|'windowSizeChange'7+|'systemAvoidAreaChange'7+) - -on(type: string, callback: Callback<AvoidArea | Size | number>): void - -开启监听。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听;
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | - | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size) \| number> | 是 | 回调返回监听到的信息。 | - -- 示例 - ``` - var type = 'windowSizeChange'; - windowClass.on(type, (data) => { - console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); - }); + console.info('Succeeded in getting window color space. Cause:' + JSON.stringify(data)) + }) ``` -### off('keyboardHeightChange'|'windowSizeChange'7+|'systemAvoidAreaChange'7+) - -off(type: string, callback?: Callback<AvoidArea | Size | number>): void - -关闭监听。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听;
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | - | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size) \| number> | 否 | 回调返回监听到的信息。 | - -- 示例 - ``` - var type = 'windowSizeChange'; - windowClass.off(type); - ``` +### \ No newline at end of file