提交 dbad4708 编写于 作者: Z zhengjiangliang

窗口子系统window错误码文档更新

Change-Id: Ia4ff0c8b3c61169c5d4719213ea67e08e4039c20
Signed-off-by: Nzhengjiangliang <zhengjiangliang@huawei.com>
上级 36e6c8d9
...@@ -44,6 +44,22 @@ import window from '@ohos.window'; ...@@ -44,6 +44,22 @@ import window from '@ohos.window';
| TYPE_DIALOG<sup>9+</sup> | 16 | 表示模态窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 | | TYPE_DIALOG<sup>9+</sup> | 16 | 表示模态窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
| TYPE_SCREENSHOT<sup>9+</sup> | 17 | 表示截屏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 | | TYPE_SCREENSHOT<sup>9+</sup> | 17 | 表示截屏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。 |
## Configuration<sup>9+</sup>
创建子窗口时的参数。
从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ---------- | ----------------------------- | -- | -- | ------------------ |
| name | string | 是 | 是 | 子窗口名字。 |
| windowType | [WindowType](#windowtype7) | 是 | 是 | 子窗口类型。 |
| ctx | [Context](js-apis-Context.md) | 是 | 是 | 当前应用上下文信息。 |
| displayId | number | 是 | 是 | 当前物理屏幕id。 |
| parentId | string | 是 | 是 | 父窗口id。 |
## AvoidAreaType<sup>7+</sup> ## AvoidAreaType<sup>7+</sup>
窗口内容需要规避区域的类型枚举。 窗口内容需要规避区域的类型枚举。
...@@ -147,7 +163,7 @@ import window from '@ohos.window'; ...@@ -147,7 +163,7 @@ import window from '@ohos.window';
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| type | [WindowType](#windowtype) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | | type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| isEnable | boolean | 是 | 否 | 当前系统栏是否显示。 | | isEnable | boolean | 是 | 否 | 当前系统栏是否显示。 |
| region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 | | region | [Rect](#rect) | 是 | 否 | 当前系统栏的位置及大小。 |
| backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 | | backgroundColor | string | 是 | 否 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
...@@ -213,7 +229,7 @@ import window from '@ohos.window'; ...@@ -213,7 +229,7 @@ import window from '@ohos.window';
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| windowRect<sup>7+</sup> | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | | windowRect<sup>7+</sup> | [Rect](#rect) | 是 | 是 | 窗口尺寸。 |
| type<sup>7+</sup> | [WindowType](#windowtype) | 是 | 是 | 窗口类型。 | | type<sup>7+</sup> | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 |
| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | | isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 |
| isLayoutFullScreen<sup>7+</sup> | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | | isLayoutFullScreen<sup>7+</sup> | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 |
| focusable<sup>7+</sup> | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | | focusable<sup>7+</sup> | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 |
...@@ -282,12 +298,15 @@ import window from '@ohos.window'; ...@@ -282,12 +298,15 @@ import window from '@ohos.window';
| y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 | | y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 |
| z | number | 否 | 是 | Z轴的平移参数,默认值为0.0。 | | z | number | 否 | 是 | Z轴的平移参数,默认值为0.0。 |
## window.create<sup>7+</sup> ## window.create<sup>(deprecated)</sup>
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
创建子窗口,使用callback异步回调。 创建子窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。
**模型约束:** 此接口仅可在FA模型下使用。 **模型约束:** 此接口仅可在FA模型下使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -297,7 +316,7 @@ create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): voi ...@@ -297,7 +316,7 @@ create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------ |
| id | string | 是 | 窗口id。 | | id | string | 是 | 窗口id。 |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的子窗口对象。 | | callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的子窗口对象。 |
**示例:** **示例:**
...@@ -314,12 +333,15 @@ window.create('first', window.WindowType.TYPE_APP,(err,data) => { ...@@ -314,12 +333,15 @@ window.create('first', window.WindowType.TYPE_APP,(err,data) => {
}); });
``` ```
## window.create<sup>7+</sup> ## window.create<sup>(deprecated)</sup>
create(id: string, type: WindowType): Promise&lt;Window&gt; create(id: string, type: WindowType): Promise&lt;Window&gt;
创建子窗口,使用Promise异步回调。 创建子窗口,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9-1)。
**模型约束:** 此接口仅可在FA模型下使用。 **模型约束:** 此接口仅可在FA模型下使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -329,7 +351,7 @@ create(id: string, type: WindowType): Promise&lt;Window&gt; ...@@ -329,7 +351,7 @@ create(id: string, type: WindowType): Promise&lt;Window&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------- | ---- | ---------- | | ------ | ------------------------- | ---- | ---------- |
| id | string | 是 | 窗口id。 | | id | string | 是 | 窗口id。 |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
**返回值:** **返回值:**
...@@ -350,7 +372,7 @@ promise.then((data)=> { ...@@ -350,7 +372,7 @@ promise.then((data)=> {
}); });
``` ```
## window.create<sup>8+</sup> ## window.create<sup>(deprecated)</sup>
create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
...@@ -358,6 +380,9 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi ...@@ -358,6 +380,9 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi
从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。 从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[createWindow()](#windowcreatewindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -366,7 +391,7 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi ...@@ -366,7 +391,7 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | 是 | 当前应用上下文信息。<br>API version 8的Context定义见[Context](js-apis-Context.md)<br>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 | | ctx | Context | 是 | 当前应用上下文信息。<br>API version 8的Context定义见[Context](js-apis-Context.md)<br>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 |
| id | string | 是 | 窗口id。 | | id | string | 是 | 窗口id。 |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的子窗口对象。 | | callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的子窗口对象。 |
**示例:** **示例:**
...@@ -384,7 +409,7 @@ let windowClass = null; ...@@ -384,7 +409,7 @@ let windowClass = null;
}); });
``` ```
## window.create<sup>8+</sup> ## window.create<sup>(deprecated)</sup>
create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt; create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
...@@ -392,6 +417,9 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt; ...@@ -392,6 +417,9 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
从API version 9开始,当Context为[ServiceExtensionContext](js-apis-service-extension-context.md)时,创建系统窗口,使用Promise异步回调。 从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 **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -400,7 +428,7 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt; ...@@ -400,7 +428,7 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
| ------ | ------------------------- | ---- | ------------------------------------------------------------ | | ------ | ------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | 是 | 当前应用上下文信息。<br/>API version 8的Context定义见[Context](js-apis-Context.md)<br/>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 | | ctx | Context | 是 | 当前应用上下文信息。<br/>API version 8的Context定义见[Context](js-apis-Context.md)<br/>API version 9的Context定义见[Context](js-apis-service-extension-context.md)。 |
| id | string | 是 | 窗口id。 | | id | string | 是 | 窗口id。 |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
**返回值:** **返回值:**
...@@ -421,12 +449,88 @@ promise.then((data)=> { ...@@ -421,12 +449,88 @@ promise.then((data)=> {
}); });
``` ```
## window.find<sup>7+</sup> ## window.createWindow<sup>9+</sup>
createWindow(config: Configuration, callback: AsyncCallback&lt;Window&lt;): void;
创建子窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | -- | --------------------------------- |
| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前创建的子窗口对象。 |
**示例:**
```js
let windowClass = null;
let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""};
try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
windowClass.resetSize(500, 1000);
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
```
## window.createWindow<sup>9+</sup>
createWindow(config: Configuration): Promise&lt;Window&lt;;
创建子窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------------------- | -- | ------------------ |
| config | [Configuration](#configuration9) | 是 | 当前应用上下文信息。 |
**返回值:**
| 类型 | 说明 |
| -------------------------------- | ------------------------------------ |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前创建的子窗口对象。 |
**示例:**
```js
let windowClass = null;
let config = {"alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, this.context, ""};
try {
let promise = window.createWindow(config);
promise.then((data)=> {
windowClass = data;
console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
};
```
## window.find<sup>(deprecated)</sup>
find(id: string, callback: AsyncCallback&lt;Window&gt;): void find(id: string, callback: AsyncCallback&lt;Window&gt;): void
查找id所对应的窗口,使用callback异步回调。 查找id所对应的窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -450,12 +554,15 @@ let windowClass = null; ...@@ -450,12 +554,15 @@ let windowClass = null;
}); });
``` ```
## window.find<sup>7+</sup> ## window.find<sup>(deprecated)</sup>
find(id: string): Promise&lt;Window&gt; find(id: string): Promise&lt;Window&gt;
查找id所对应的窗口,使用Promise异步回调。 查找id所对应的窗口,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[findWindow()](#windowfindwindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -483,12 +590,45 @@ promise.then((data)=> { ...@@ -483,12 +590,45 @@ promise.then((data)=> {
}); });
``` ```
## window.getTopWindow ## window.findWindow<sup>9+</sup>
findWindow(name: string): Window;
查找name所对应的窗口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------- |
| name | string | 是 | 窗口id。 |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------- |
| [Window](#window) | 当前查找的窗口对象。 |
**示例:**
```js
try {
let windowClass = window.findWindow('alertWindow');
} catch (exception) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception));
};
```
## window.getTopWindow<sup>(deprecated)</sup>
getTopWindow(callback: AsyncCallback&lt;Window&gt;): void getTopWindow(callback: AsyncCallback&lt;Window&gt;): void
获取当前应用内最后显示的窗口,使用callback异步回调。 获取当前应用内最后显示的窗口,使用callback异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。
**模型约束:** 此接口仅可在FA模型下使用。 **模型约束:** 此接口仅可在FA模型下使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -513,12 +653,15 @@ window.getTopWindow((err, data) => { ...@@ -513,12 +653,15 @@ window.getTopWindow((err, data) => {
}); });
``` ```
## window.getTopWindow ## window.getTopWindow<sup>(deprecated)</sup>
getTopWindow(): Promise&lt;Window&gt; getTopWindow(): Promise&lt;Window&gt;
获取当前应用内最后显示的窗口,使用Promise异步回调。 获取当前应用内最后显示的窗口,使用Promise异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。
**模型约束:** 此接口仅可在FA模型下使用。 **模型约束:** 此接口仅可在FA模型下使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -542,12 +685,15 @@ promise.then((data)=> { ...@@ -542,12 +685,15 @@ promise.then((data)=> {
}) })
``` ```
## window.getTopWindow<sup>8+</sup> ## window.getTopWindow<sup>(deprecated)</sup>
getTopWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void getTopWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void
获取当前应用内最后显示的窗口,使用callback异步回调。 获取当前应用内最后显示的窗口,使用callback异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -571,12 +717,15 @@ window.getTopWindow(this.context, (err, data) => { ...@@ -571,12 +717,15 @@ window.getTopWindow(this.context, (err, data) => {
}); });
``` ```
## window.getTopWindow<sup>8+</sup> ## window.getTopWindow<sup>(deprecated)</sup>
getTopWindow(ctx: Context): Promise&lt;Window&gt; getTopWindow(ctx: Context): Promise&lt;Window&gt;
获取当前应用内最后显示的窗口,使用Promise异步回调。 获取当前应用内最后显示的窗口,使用Promise异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getLastWindow()](#windowgetlastwindow9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -604,6 +753,76 @@ promise.then((data)=> { ...@@ -604,6 +753,76 @@ promise.then((data)=> {
}) })
``` ```
## window.getLastWindow<sup>9+</sup>
getLastWindow(ctx: Context, callback: AsyncCallback&lt;Window&gt;): void
获取当前应用内最后显示的窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | -- | ---------------------------------------- |
| ctx | Context | 是 | 当前应用上下文信息。<br>API version 8的Context定义见[Context](js-apis-Context.md)<br>API version 9的Context定义见[Context](js-apis-ability-context.md)。 |
| callback | AsyncCallback&lt;[Window](#window)&gt; | 是 | 回调函数。返回当前应用内最后显示的窗口对象。 |
**示例:**
```js
let windowClass = null;
try {
window.getLastWindow(this.context, (err, data) => {
if (err.code) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
```
## window.getLastWindow<sup>9+</sup>
getLastWindow(ctx: Context): Promise&lt;Window&gt;
获取当前应用内最后显示的窗口,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| ctx | Context | 是 | 当前应用上下文信息。<br/>API version 8的Context定义见[Context](js-apis-Context.md)<br/>API version 9的Context定义见[Context](js-apis-ability-context.md)。 |
**返回值:**
| 类型 | 说明 |
| -------------------------------- | ------------------------------------------- |
| Promise&lt;[Window](#window)&gt; | Promise对象。返回当前应用内最后显示的窗口对象。 |
**示例:**
```js
let windowClass = null;
try {
let promise = window.getLastWindow(this.context);
promise.then((data)=> {
windowClass = data;
console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
};
```
## window.minimizeAll<sup>9+</sup> ## window.minimizeAll<sup>9+</sup>
minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
...@@ -632,6 +851,7 @@ display.getDefaultDisplay((err, data) => { ...@@ -632,6 +851,7 @@ display.getDefaultDisplay((err, data) => {
return; return;
} }
displayClass = data; displayClass = data;
try {
window.minimizeAll(displayClass.id, (err, data) => { window.minimizeAll(displayClass.id, (err, data) => {
if(err.code) { if(err.code) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
...@@ -639,6 +859,9 @@ display.getDefaultDisplay((err, data) => { ...@@ -639,6 +859,9 @@ display.getDefaultDisplay((err, data) => {
} }
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}); });
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
};
}); });
``` ```
...@@ -675,12 +898,16 @@ display.getDefaultDisplay((err, data) => { ...@@ -675,12 +898,16 @@ display.getDefaultDisplay((err, data) => {
return; return;
} }
displayClass = data; displayClass = data;
try {
let promise = window.minimizeAll(displayClass.id); let promise = window.minimizeAll(displayClass.id);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in minimizing all windows.'); console.info('Succeeded in minimizing all windows.');
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
}) });
} catch (exception) {
console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
};
}); });
``` ```
...@@ -756,9 +983,13 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;) ...@@ -756,9 +983,13 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;)
**示例:** **示例:**
```js ```js
window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => { try {
window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (data) => {
console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
``` ```
## window.setWindowLayoutMode<sup>9+</sup> ## window.setWindowLayoutMode<sup>9+</sup>
...@@ -785,12 +1016,16 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt; ...@@ -785,12 +1016,16 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); try {
promise.then((data)=> { 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)); console.info('Succeeded in setting window layout mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err)); console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
}) });
} catch (exception) {
console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
};
``` ```
## on('systemBarTintChange')<sup>8+</sup> ## on('systemBarTintChange')<sup>8+</sup>
...@@ -813,9 +1048,13 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v ...@@ -813,9 +1048,13 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v
**示例:** **示例:**
```js ```js
window.on('systemBarTintChange', (data) => { try {
window.on('systemBarTintChange', (data) => {
console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
};
``` ```
## off('systemBarTintChange')<sup>8+</sup> ## off('systemBarTintChange')<sup>8+</sup>
...@@ -838,7 +1077,11 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;) ...@@ -838,7 +1077,11 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;)
**示例:** **示例:**
```js ```js
window.off('systemBarTintChange'); try {
window.off('systemBarTintChange');
} catch (exception) {
console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
};
``` ```
## Window ## Window
...@@ -957,12 +1200,15 @@ promise.then((data)=> { ...@@ -957,12 +1200,15 @@ promise.then((data)=> {
}) })
``` ```
### show<sup>7+</sup> ### show<sup>(deprecated)</sup>
show(callback: AsyncCallback&lt;void&gt;): void show(callback: AsyncCallback&lt;void&gt;): void
显示当前窗口,使用callback异步回调。 显示当前窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -983,12 +1229,15 @@ windowClass.show((err, data) => { ...@@ -983,12 +1229,15 @@ windowClass.show((err, data) => {
}) })
``` ```
### show<sup>7+</sup> ### show<sup>(deprecated)</sup>
show(): Promise&lt;void&gt; show(): Promise&lt;void&gt;
显示当前窗口,使用Promise异步回调。 显示当前窗口,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[showWindow()](#showwindow9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:** **返回值:**
...@@ -1008,6 +1257,57 @@ promise.then((data)=> { ...@@ -1008,6 +1257,57 @@ promise.then((data)=> {
}) })
``` ```
### showWindow<sup>9+</sup>
showWindow(callback: AsyncCallback&lt;void&gt;): void
显示当前窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | -- | --------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
windowClass.showWindow((err, data) => {
if (err.code) {
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
});
```
### showWindow<sup>9+</sup>
showWindow(): Promise&lt;void&gt;
显示当前窗口,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ------------------- | ----------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let promise = windowClass.showWindow();
promise.then((data)=> {
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to show the window. Cause: ' + JSON.stringify(err));
});
```
### showWithAnimation<sup>9+</sup> ### showWithAnimation<sup>9+</sup>
showWithAnimation(callback: AsyncCallback&lt;void&gt;): void showWithAnimation(callback: AsyncCallback&lt;void&gt;): void
...@@ -1063,12 +1363,15 @@ promise.then((data)=> { ...@@ -1063,12 +1363,15 @@ promise.then((data)=> {
}) })
``` ```
### destroy<sup>7+</sup> ### destroy<sup>(deprecated)</sup>
destroy(callback: AsyncCallback&lt;void&gt;): void destroy(callback: AsyncCallback&lt;void&gt;): void
销毁当前窗口,使用callback异步回调。 销毁当前窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1089,12 +1392,15 @@ windowClass.destroy((err, data) => { ...@@ -1089,12 +1392,15 @@ windowClass.destroy((err, data) => {
}) })
``` ```
### destroy<sup>7+</sup> ### destroy<sup>(deprecated)</sup>
destroy(): Promise&lt;void&gt; destroy(): Promise&lt;void&gt;
销毁当前窗口,使用Promise异步回调。 销毁当前窗口,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[destroyWindow()](#destroywindow9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:** **返回值:**
...@@ -1114,73 +1420,201 @@ promise.then((data)=> { ...@@ -1114,73 +1420,201 @@ promise.then((data)=> {
}) })
``` ```
### moveTo<sup>7+</sup> ### destroyWindow<sup>9+</sup>
moveTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void destroyWindow(callback: AsyncCallback&lt;void&gt;): void
移动窗口位置,使用callback异步回调。 销毁当前窗口,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------- | | -------- | ------------------------- | -- | --------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
windowClass.moveTo(300, 300, (err, data)=>{ windowClass.destroyWindow((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
})
});
``` ```
### moveTo<sup>7+</sup> ### destroyWindow<sup>9+</sup>
moveTo(x: number, y: number): Promise&lt;void&gt; destroyWindow(): Promise&lt;void&gt;
移动窗口位置,使用Promise异步回调。 销毁当前窗口,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------------------- | | ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
let promise = windowClass.moveTo(300, 300); let promise = windowClass.destroyWindow();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));
}) })
``` ```
### resetSize<sup>7+</sup> ### moveTo<sup>(deprecated)</sup>
resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void moveTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
移动窗口位置,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowTo9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```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<sup>(deprecated)</sup>
moveTo(x: number, y: number): Promise&lt;void&gt;
移动窗口位置,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[moveWindowTo()](#movewindowTo9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let promise = windowClass.moveTo(300, 300);
promise.then((data)=> {
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
})
```
### moveWindowTo<sup>9+</sup>
moveWindowTo(x: number, y: number, callback: AsyncCallback&lt;void&gt;): void
移动窗口位置,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | -- | --------------------------------------------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
try {
windowClass.moveWindowTo(300, 300, (err, data)=>{
if (err.code) {
console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
```
### moveWindowTo<sup>9+</sup>
moveWindowTo(x: number, y: number): Promise&lt;void&gt;
移动窗口位置,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -- | ----- | -- | --------------------------------------------- |
| x | number | 是 | 窗口在x轴方向移动的值,值为正表示右移,单位为px。 |
| y | number | 是 | 窗口在y轴方向移动的值,值为正表示下移,单位为px。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
try {
let promise = windowClass.moveWindowTo(300, 300);
promise.then((data)=> {
console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to move the window. Cause:' + JSON.stringify(exception));
};
```
### resetSize<sup>(deprecated)</sup>
resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
改变当前窗口大小,使用callback异步回调。 改变当前窗口大小,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1203,12 +1637,15 @@ windowClass.resetSize(500, 1000, (err, data) => { ...@@ -1203,12 +1637,15 @@ windowClass.resetSize(500, 1000, (err, data) => {
}); });
``` ```
### resetSize<sup>7+</sup> ### resetSize<sup>(deprecated)</sup>
resetSize(width: number, height: number): Promise&lt;void&gt; resetSize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。 改变当前窗口大小,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1235,6 +1672,74 @@ promise.then((data)=> { ...@@ -1235,6 +1672,74 @@ promise.then((data)=> {
}); });
``` ```
### resize<sup>9+</sup>
resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
改变当前窗口大小,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | -- | ------------------------ |
| width | number | 是 | 目标窗口的宽度,单位为px。 |
| height | number | 是 | 目标窗口的高度,单位为px。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
try {
windowClass.resize(500, 1000, (err, data) => {
if (err.code) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to change the window size. Cause:' + JSON.stringify(exception));
};
```
### resize<sup>9+</sup>
resize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | -- | ------------------------ |
| width | number | 是 | 目标窗口的宽度,单位为px。 |
| height | number | 是 | 目标窗口的高度,单位为px。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
try {
let promise = windowClass.resize(500, 1000);
promise.then((data)=> {
console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception));
};
```
### setWindowType<sup>(deprecated)</sup> ### setWindowType<sup>(deprecated)</sup>
setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void
...@@ -1253,7 +1758,7 @@ setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void ...@@ -1253,7 +1758,7 @@ setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- | | -------- | ------------------------- | ---- | ---------- |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
...@@ -1287,7 +1792,7 @@ setWindowType(type: WindowType): Promise&lt;void&gt; ...@@ -1287,7 +1792,7 @@ setWindowType(type: WindowType): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------- | ---- | ---------- | | ------ | ------------------------- | ---- | ---------- |
| type | [WindowType](#windowtype) | 是 | 窗口类型。 | | type | [WindowType](#windowtype7) | 是 | 窗口类型。 |
**返回值:** **返回值:**
...@@ -1307,12 +1812,87 @@ promise.then((data)=> { ...@@ -1307,12 +1812,87 @@ promise.then((data)=> {
}); });
``` ```
### getProperties ### setWindowMode<sup>9+</sup>
setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void
设置窗口模式,使用callback异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | -- | --------- |
| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
let mode = window.WindowMode.FULLSCREEN;
try {
windowClass.setWindowMode(mode, (err, data) => {
if (err.code) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window mode. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
```
### setWindowMode<sup>9+</sup>
setWindowMode(mode: WindowMode): Promise&lt;void&gt;
设置窗口类型,使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | -- | --------- |
| mode | [WindowMode](#windowmode7) | 是 | 窗口类型。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ----------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let mode = window.WindowMode.FULLSCREEN;
try {
let promise = windowClass.setWindowMode(type);
promise.then((data)=> {
console.info('Succeeded in setting the window mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
};
```
### getProperties<sup>(deprecated)</sup>
getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void getProperties(callback: AsyncCallback&lt;WindowProperties&gt;): void
获取当前窗口的属性,使用callback异步回调,返回WindowProperties。 获取当前窗口的属性,使用callback异步回调,返回WindowProperties。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1333,12 +1913,15 @@ windowClass.getProperties((err, data) => { ...@@ -1333,12 +1913,15 @@ windowClass.getProperties((err, data) => {
}); });
``` ```
### getProperties ### getProperties<sup>(deprecated)</sup>
getProperties(): Promise&lt;WindowProperties&gt; getProperties(): Promise&lt;WindowProperties&gt;
获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。 获取当前窗口的属性,使用Promise异步回调,返回WindowProperties。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowproperties9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:** **返回值:**
...@@ -1358,12 +1941,39 @@ promise.then((data)=> { ...@@ -1358,12 +1941,39 @@ promise.then((data)=> {
}); });
``` ```
### getAvoidArea<sup>7+</sup> ### getWindowProperties<sup>9+</sup>
getWindowProperties(): WindowProperties
获取当前窗口的属性,返回WindowProperties。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ------------------------------------- | ------------- |
| [WindowProperties](#windowproperties) | 当前窗口属性。 |
**示例:**
```js
try {
let properties = windowClass.getWindowProperties();
} catch (exception) {
console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception));
};
```
### getAvoidArea<sup>(deprecated)</sup>
getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void getAvoidArea(type: [AvoidAreaType](#avoidareatype7), callback: AsyncCallback&lt;[AvoidArea](#avoidarea7)&gt;): void
获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowAvoidArea()](#getwindowavoidarea9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1386,12 +1996,15 @@ windowClass.getAvoidArea(type, (err, data) => { ...@@ -1386,12 +1996,15 @@ windowClass.getAvoidArea(type, (err, data) => {
}); });
``` ```
### getAvoidArea<sup>7+</sup> ### getAvoidArea<sup>(deprecated)</sup>
getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt; getAvoidArea(type: [AvoidAreaType](#avoidareatype7)): Promise&lt;[AvoidArea](#avoidarea7)&gt;
获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。 获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindowProperties()](#getwindowavoidarea9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1418,12 +2031,46 @@ promise.then((data)=> { ...@@ -1418,12 +2031,46 @@ promise.then((data)=> {
}); });
``` ```
### setFullScreen ### getWindowAvoidArea<sup>9+</sup>
getWindowAvoidArea(type: [AvoidAreaType](#avoidareatype7)): [AvoidArea](#avoidarea7)
获取窗口内容规避的区域,如系统的系统栏区域、凹凸区域。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- |----------------------------------| -- | ------------------------------------------------------------ |
| type | [AvoidAreaType](#avoidareatype7) | 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。type为TYPE_SYSTEM_GESTURE,表示手势区域。type为TYPE_KEYBOARD,表示软键盘区域。 |
**返回值:**
| 类型 | 说明 |
|--------------------------| ----------------- |
| [AvoidArea](#avoidarea7) | 窗口内容规避区域。 |
**示例:**
```js
let type = window.AvoidAreaType.TYPE_SYSTEM;
try {
let avoidArea = windowClass.getWindowAvoidArea(type);
} catch (exception) {
console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
};
```
### setFullScreen<sup>(deprecated)</sup>
setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void setFullScreen(isFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
设置是否为全屏状态,使用callback异步回调。 设置是否为全屏状态,使用callback异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1446,12 +2093,15 @@ windowClass.setFullScreen(isFullScreen, (err, data) => { ...@@ -1446,12 +2093,15 @@ windowClass.setFullScreen(isFullScreen, (err, data) => {
}); });
``` ```
### setFullScreen ### setFullScreen<sup>(deprecated)</sup>
setFullScreen(isFullScreen: boolean): Promise&lt;void&gt; setFullScreen(isFullScreen: boolean): Promise&lt;void&gt;
设置是否为全屏状态,使用Promise异步回调。 设置是否为全屏状态,使用Promise异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1478,12 +2128,15 @@ promise.then((data)=> { ...@@ -1478,12 +2128,15 @@ promise.then((data)=> {
}); });
``` ```
### setLayoutFullScreen<sup>7+</sup> ### setLayoutFullScreen<sup>(deprecated)</sup>
setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口的布局是否为全屏显示状态,使用callback异步回调。 设置窗口的布局是否为全屏显示状态,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1506,12 +2159,15 @@ windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { ...@@ -1506,12 +2159,15 @@ windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => {
}); });
``` ```
### setLayoutFullScreen<sup>7+</sup> ### setLayoutFullScreen<sup>(deprecated)</sup>
setLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt; setLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;
设置窗口的布局是否为全屏显示状态,使用Promise异步回调。 设置窗口的布局是否为全屏显示状态,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1538,12 +2194,83 @@ promise.then((data)=> { ...@@ -1538,12 +2194,83 @@ promise.then((data)=> {
}); });
``` ```
### setSystemBarEnable<sup>7+</sup> ### setWindowLayoutFullScreen<sup>9+</sup>
setWindowLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口的布局是否为全屏显示状态,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------------ | ------------------------- | -- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
let isLayoutFullScreen= true;
try {
windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err, data) => {
if (err.code) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
```
### setWindowLayoutFullScreen<sup>9+</sup>
setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise&lt;void&gt;
设置窗口的布局是否为全屏显示状态,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------------ | ------- | -- | ------------------------------------------------------------ |
| isLayoutFullScreen | boolean | 是 | 窗口的布局是否为全屏显示状态,且全屏状态下状态栏、导航栏仍然显示。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let isLayoutFullScreen = true;
try {
let promise = windowClass.setWindowLayoutFullScreen(isLayoutFullScreen);
promise.then((data)=> {
console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception));
};
```
### setSystemBarEnable<sup>(deprecated)</sup>
setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
设置导航栏、状态栏的可见模式,使用callback异步回调。 设置导航栏、状态栏的可见模式,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1560,26 +2287,175 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac ...@@ -1560,26 +2287,175 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac
let names = []; let names = [];
windowClass.setSystemBarEnable(names, (err, data) => { windowClass.setSystemBarEnable(names, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); 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));
});
```
### setSystemBarEnable<sup>(deprecated)</sup>
setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
设置导航栏、状态栏的可见模式,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----- | ---- | ------------------------------------------------------------ |
| names | Array | 是 | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```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));
});
```
### setWindowSystemBarEnable<sup>9+</sup>
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback&lt;void&gt;): void
设置导航栏、状态栏的可见模式,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | -- | --------- |
| names | Array | 是 | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```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));
});
} catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
};
```
### setWindowSystemBarEnable<sup>9+</sup>
setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
设置导航栏、状态栏的可见模式,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----- | -- | ------------------------------------------------------------------------------------------------------------ |
| names | Array | 是 | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
// 此处以不显示导航栏、状态栏为例
let names = [];
try {
let promise = windowClass.setWindowSystemBarEnable(names);
promise.then((data)=> {
console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception));
};
```
### setSystemBarProperties<sup>(deprecated)</sup>
setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
设置窗口内导航栏、状态栏的属性,使用callback异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------------- | ------------------------------------------- | ---- | ---------------------- |
| SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
let SystemBarProperties={
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
//以下两个属性从API Version7开始支持
isStatusBarLightIcon: true,
isNavigationBarLightIcon:false,
//以下两个属性从API Version8开始支持
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => {
if (err.code) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}); });
``` ```
### setSystemBarEnable<sup>7+</sup> ### setSystemBarProperties<sup>(deprecated)</sup>
setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt; setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
设置导航栏、状态栏的可见模式,使用Promise异步回调。 设置窗口内导航栏、状态栏的属性,使用Promise异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----- | ---- | ------------------------------------------------------------ | | ------------------- | ------------------------------------------- | ---- | ---------------------- |
| names | Array | 是 | 设置状态栏和导航栏是否显示。<br>例如,需全部显示,该参数设置为['status',&nbsp;'navigation'];不设置,则默认不显示。 | | SystemBarProperties | [SystemBarProperties](#systembarproperties) | 是 | 导航栏、状态栏的属性。 |
**返回值:** **返回值:**
...@@ -1590,19 +2466,27 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt; ...@@ -1590,19 +2466,27 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
// 此处以不显示导航栏、状态栏为例 let SystemBarProperties={
let names = []; statusBarColor: '#ff00ff',
let promise = windowClass.setSystemBarEnable(names); navigationBarColor: '#00ff00',
//以下两个属性从API Version7开始支持
isStatusBarLightIcon: true,
isNavigationBarLightIcon:false,
//以下两个属性从API Version8开始支持
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
let promise = windowClass.setSystemBarProperties(SystemBarProperties);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setSystemBarProperties ### setWindowSystemBarProperties<sup>(deprecated)</sup>
setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback&lt;void&gt;): void
设置窗口内导航栏、状态栏的属性,使用callback异步回调。 设置窗口内导航栏、状态栏的属性,使用callback异步回调。
...@@ -1628,18 +2512,22 @@ let SystemBarProperties={ ...@@ -1628,18 +2512,22 @@ let SystemBarProperties={
statusBarContentColor:'#ffffff', statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff' navigationBarContentColor:'#00ffff'
}; };
windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { try {
windowClass.setWindowSystemBarProperties(SystemBarProperties, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
};
``` ```
### setSystemBarProperties ### setWindowSystemBarProperties<sup>(deprecated)</sup>
setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt; setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise&lt;void&gt;
设置窗口内导航栏、状态栏的属性,使用Promise异步回调。 设置窗口内导航栏、状态栏的属性,使用Promise异步回调。
...@@ -1670,12 +2558,16 @@ let SystemBarProperties={ ...@@ -1670,12 +2558,16 @@ let SystemBarProperties={
statusBarContentColor:'#ffffff', statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff' navigationBarContentColor:'#00ffff'
}; };
let promise = windowClass.setSystemBarProperties(SystemBarProperties); try {
promise.then((data)=> { let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties);
promise.then((data)=> {
console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(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));
};
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -1697,13 +2589,17 @@ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback&lt;voi ...@@ -1697,13 +2589,17 @@ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback&lt;voi
```js ```js
let orientation = window.Orientation.AUTO_ROTATION; let orientation = window.Orientation.AUTO_ROTATION;
windowClass.setPreferredOrientation(orientation, (err, data) => { try {
windowClass.setPreferredOrientation(orientation, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err)); console.error('Failed to set window orientation. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting window orientation. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception));
};
``` ```
### setPreferredOrientation<sup>9+</sup> ### setPreferredOrientation<sup>9+</sup>
...@@ -1730,20 +2626,27 @@ setPreferredOrientation(orientation: Orientation): Promise&lt;void&gt; ...@@ -1730,20 +2626,27 @@ setPreferredOrientation(orientation: Orientation): Promise&lt;void&gt;
```js ```js
let orientation = window.Orientation.AUTO_ROTATION; let orientation = window.Orientation.AUTO_ROTATION;
let promise = windowClass.setPreferredOrientation(orientation); try {
promise.then((data)=> { let promise = windowClass.setPreferredOrientation(orientation);
promise.then((data)=> {
console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the window orientation. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window orientation. Cause: ' + JSON.stringify(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));
};
``` ```
### loadContent<sup>7+</sup> ### loadContent<sup>(deprecated)</sup>
loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void loadContent(path: string, callback: AsyncCallback&lt;void&gt;): void
为当前窗口加载具体页面内容,使用callback异步回调。 为当前窗口加载具体页面内容,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1765,12 +2668,15 @@ windowClass.loadContent('pages/page2/page2', (err, data) => { ...@@ -1765,12 +2668,15 @@ windowClass.loadContent('pages/page2/page2', (err, data) => {
}); });
``` ```
### loadContent<sup>7+</sup> ### loadContent<sup>(deprecated)</sup>
loadContent(path: string): Promise&lt;void&gt; loadContent(path: string): Promise&lt;void&gt;
为当前窗口加载具体页面内容,使用Promise异步回调。 为当前窗口加载具体页面内容,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setUIContent()](#setuicontent9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1795,6 +2701,73 @@ promise.then((data)=> { ...@@ -1795,6 +2701,73 @@ promise.then((data)=> {
console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
}); });
``` ```
### setUIContent<sup>9+</sup>
setUIContent(path: string, callback: AsyncCallback&lt;void&gt;): void
为当前窗口加载具体页面内容,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | -- | -------------------- |
| path | string | 是 | 设置加载页面的路径。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
try {
windowClass.setUIContent('pages/page2/page2', (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
```
### setUIContent<sup>9+</sup>
setUIContent(path: string): Promise&lt;void&gt;
为当前窗口加载具体页面内容,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | -- | ------------------ |
| path | string | 是 | 设置加载页面的路径。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
try {
let promise = windowClass.setUIContent('pages/page2/page2');
promise.then((data)=> {
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to load the content. Cause: ' + JSON.stringify(exception));
};
```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void&gt;): void
...@@ -1822,6 +2795,7 @@ class myAbility extends Ability { ...@@ -1822,6 +2795,7 @@ class myAbility extends Ability {
this.storage = new LocalStorage(); this.storage = new LocalStorage();
this.storage.setOrCreate('storageSimpleProp',121); this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.loadContent('pages/page2',this.storage,(err, data) => { windowStage.loadContent('pages/page2',this.storage,(err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
...@@ -1829,6 +2803,9 @@ class myAbility extends Ability { ...@@ -1829,6 +2803,9 @@ class myAbility extends Ability {
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -1866,22 +2843,30 @@ class myAbility extends Ability { ...@@ -1866,22 +2843,30 @@ class myAbility extends Ability {
this.storage.setOrCreate('storageSimpleProp',121); this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try {
let promise = windowStage.loadContent('pages/page2',this.storage); let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to load the content. Cause:' + JSON.stringify(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));
};
} }
} }
``` ```
### isShowing<sup>7+</sup>
### isShowing<sup>(deprecated)</sup>
isShowing(callback: AsyncCallback&lt;boolean&gt;): void isShowing(callback: AsyncCallback&lt;boolean&gt;): void
判断当前窗口是否已显示,使用callback异步回调。 判断当前窗口是否已显示,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1902,12 +2887,15 @@ windowClass.isShowing((err, data) => { ...@@ -1902,12 +2887,15 @@ windowClass.isShowing((err, data) => {
}); });
``` ```
### isShowing<sup>7+</sup> ### isShowing<sup>(deprecated)</sup>
isShowing(): Promise&lt;boolean&gt; isShowing(): Promise&lt;boolean&gt;
判断当前窗口是否已显示,使用Promise异步回调。 判断当前窗口是否已显示,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[isWindowShowing()](#iswindowshowing9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:** **返回值:**
...@@ -1927,6 +2915,31 @@ promise.then((data)=> { ...@@ -1927,6 +2915,31 @@ promise.then((data)=> {
}); });
``` ```
### isWindowShowing<sup>(deprecated)</sup>
isWindowShowing(): boolean;
判断当前窗口是否已显示。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ------- | ------------------------------------------------------- |
| boolean | 返回true表示当前窗口已显示,返回false则表示当前窗口未显示。 |
**示例:**
```js
try {
let data = windowClass.isWindowShowing();
console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data));
} catch (exception) {
console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception));
};
```
### on('windowSizeChange')<sup>7+</sup> ### on('windowSizeChange')<sup>7+</sup>
on(type: 'windowSizeChange', callback: Callback&lt;Size&gt;): void on(type: 'windowSizeChange', callback: Callback&lt;Size&gt;): void
...@@ -1945,9 +2958,13 @@ on(type: 'windowSizeChange', callback: Callback&lt;Size&gt;): void ...@@ -1945,9 +2958,13 @@ on(type: 'windowSizeChange', callback: Callback&lt;Size&gt;): void
**示例:** **示例:**
```js ```js
windowClass.on('windowSizeChange', (data) => { try {
windowClass.on('windowSizeChange', (data) => {
console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for window size changes. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('windowSizeChange')<sup>7+</sup> ### off('windowSizeChange')<sup>7+</sup>
...@@ -1968,7 +2985,11 @@ off(type: 'windowSizeChange', callback?: Callback&lt;Size &gt;): void ...@@ -1968,7 +2985,11 @@ off(type: 'windowSizeChange', callback?: Callback&lt;Size &gt;): void
**示例:** **示例:**
```js ```js
windowClass.off('windowSizeChange'); try {
windowClass.off('windowSizeChange');
} catch (exception) {
console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### on('systemAvoidAreaChange')<sup>(deprecated)</sup> ### on('systemAvoidAreaChange')<sup>(deprecated)</sup>
...@@ -2021,7 +3042,6 @@ off(type: 'systemAvoidAreaChange', callback?: Callback&lt;[AvoidArea](#avoidarea ...@@ -2021,7 +3042,6 @@ off(type: 'systemAvoidAreaChange', callback?: Callback&lt;[AvoidArea](#avoidarea
windowClass.off('systemAvoidAreaChange'); windowClass.off('systemAvoidAreaChange');
``` ```
### on('avoidAreaChange')<sup>9+</sup> ### on('avoidAreaChange')<sup>9+</sup>
on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatype7), [AvoidArea](#avoidarea7)}&gt;): void
...@@ -2040,9 +3060,14 @@ on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatyp ...@@ -2040,9 +3060,14 @@ on(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareatyp
**示例:** **示例:**
```js ```js
windowClass.on('avoidAreaChange', (data) => { try {
console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); windowClass.on('avoidAreaChange', (data) => {
}); console.info('Succeeded in enabling the listener for system avoid area changes. type:' +
JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area));
});
} catch (exception) {
console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('avoidAreaChange')<sup>9+</sup> ### off('avoidAreaChange')<sup>9+</sup>
...@@ -2063,7 +3088,11 @@ off(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareaty ...@@ -2063,7 +3088,11 @@ off(type: 'avoidAreaChange', callback: Callback&lt;{[AvoidAreaType](#avoidareaty
**示例:** **示例:**
```js ```js
windowClass.off('avoidAreaChange'); try {
windowClass.off('avoidAreaChange');
} catch (exception) {
console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### on('keyboardHeightChange')<sup>7+</sup> ### on('keyboardHeightChange')<sup>7+</sup>
...@@ -2084,9 +3113,13 @@ on(type: 'keyboardHeightChange', callback: Callback&lt;number&gt;): void ...@@ -2084,9 +3113,13 @@ on(type: 'keyboardHeightChange', callback: Callback&lt;number&gt;): void
**示例:** **示例:**
```js ```js
windowClass.on('keyboardHeightChange', (data) => { try {
windowClass.on('keyboardHeightChange', (data) => {
console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('keyboardHeightChange')<sup>7+</sup> ### off('keyboardHeightChange')<sup>7+</sup>
...@@ -2107,7 +3140,11 @@ off(type: 'keyboardHeightChange', callback?: Callback&lt;number&gt;): void ...@@ -2107,7 +3140,11 @@ off(type: 'keyboardHeightChange', callback?: Callback&lt;number&gt;): void
**示例:** **示例:**
```js ```js
windowClass.off('keyboardHeightChange'); try {
windowClass.off('keyboardHeightChange');
} catch (exception) {
console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception));
};
``` ```
### on('touchOutside')<sup>9+</sup> ### on('touchOutside')<sup>9+</sup>
...@@ -2130,9 +3167,13 @@ on(type: 'touchOutside', callback: Callback&lt;void&gt;): void ...@@ -2130,9 +3167,13 @@ on(type: 'touchOutside', callback: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
windowClass.on('touchOutside', () => { try {
windowClass.on('touchOutside', () => {
console.info('touch outside'); console.info('touch outside');
}); });
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('touchOutside')<sup>9+</sup> ### off('touchOutside')<sup>9+</sup>
...@@ -2155,7 +3196,11 @@ off(type: 'touchOutside', callback?: Callback&lt;void&gt;): void ...@@ -2155,7 +3196,11 @@ off(type: 'touchOutside', callback?: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
windowClass.off('touchOutside'); try {
windowClass.off('touchOutside');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### on('screenshot')<sup>9+</sup> ### on('screenshot')<sup>9+</sup>
...@@ -2176,9 +3221,13 @@ on(type: 'screenshot', callback: Callback&lt;void&gt;): void ...@@ -2176,9 +3221,13 @@ on(type: 'screenshot', callback: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
windowClass.on('screenshot', () => { try {
windowClass.on('screenshot', () => {
console.info('screenshot happened'); console.info('screenshot happened');
}); });
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('screenshot')<sup>9+</sup> ### off('screenshot')<sup>9+</sup>
...@@ -2202,11 +3251,18 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void ...@@ -2202,11 +3251,18 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void
let callback = ()=>{ let callback = ()=>{
console.info('screenshot happened'); console.info('screenshot happened');
} }
windowClass.on('screenshot', callback) try {
windowClass.off('screenshot', callback) windowClass.on('screenshot', callback);
} catch (exception) {
// 如果通过on开启多个callback进行监听,同时关闭所有监听: console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
windowClass.off('screenshot'); };
try {
windowClass.off('screenshot', callback);
// 如果通过on开启多个callback进行监听,同时关闭所有监听:
windowClass.off('screenshot');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### on('dialogTargetTouch')<sup>9+</sup> ### on('dialogTargetTouch')<sup>9+</sup>
...@@ -2227,9 +3283,13 @@ on(type: 'dialogTargetTouch', callback: Callback&lt;void&gt;): void ...@@ -2227,9 +3283,13 @@ on(type: 'dialogTargetTouch', callback: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
windowClass.on('dialogTargetTouch', () => { try {
windowClass.on('dialogTargetTouch', () => {
console.info('touch dialog target'); console.info('touch dialog target');
}); });
} catch (exception) {
console.error('Failed to register callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### off('dialogTargetTouch')<sup>9+</sup> ### off('dialogTargetTouch')<sup>9+</sup>
...@@ -2250,7 +3310,11 @@ off(type: 'dialogTargetTouch', callback?: Callback&lt;void&gt;): void ...@@ -2250,7 +3310,11 @@ off(type: 'dialogTargetTouch', callback?: Callback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
windowClass.off('dialogTargetTouch'); try {
windowClass.off('dialogTargetTouch');
} catch (exception) {
console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception));
};
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2294,15 +3358,19 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -2294,15 +3358,19 @@ class TestRemoteObject extends rpc.RemoteObject {
} }
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
windowClass.bindDialogTarget(token, () => { try {
windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
}, (err, data) => { }, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
};
``` ```
### bindDialogTarget<sup>9+</sup> ### bindDialogTarget<sup>9+</sup>
...@@ -2311,59 +3379,120 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): ...@@ -2311,59 +3379,120 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;):
绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。 绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | -------------------- |
| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 |
| deathCallback | Callback&lt;void&gt; | 是 | 模态窗口销毁监听。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```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((data)=> {
console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
};
```
### isSupportWideGamut<sup>(deprecated)</sup>
isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
判断当前窗口是否支持广色域模式,使用callback异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:**
```js
windowClass.isSupportWideGamut((err, data) => {
if (err.code) {
console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
})
```
### isSupportWideGamut<sup>(deprecated)</sup>
isSupportWideGamut(): Promise&lt;boolean&gt;
**系统能力:** SystemCapability.WindowManager.WindowManager.Core 判断当前窗口是否支持广色域模式,使用Promise异步回调。
**参数:** > **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[isWindowSupportWideGamut()](#iswindowsupportwidegamut9-1)。
| 参数名 | 类型 | 必填 | 说明 | **系统能力:** SystemCapability.WindowManager.WindowManager.Core
| ----------- | ------------------------- | ---- | -------------------- |
| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 目标窗口token值。 |
| deathCallback | Callback&lt;void&gt; | 是 | 模态窗口销毁监听。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------------------- | | ---------------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:** **示例:**
```js ```js
class MyDeathRecipient { let promise = windowClass.isSupportWideGamut();
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 promise = windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.');
});
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err));
}); });
``` ```
### isSupportWideGamut<sup>8+</sup> ### isWindowSupportWideGamut<sup>9+</sup>
isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void isWindowSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
判断当前窗口是否支持广色域模式,使用callback异步回调。 判断当前窗口是否支持广色域模式,使用callback异步回调。
...@@ -2372,24 +3501,24 @@ isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2372,24 +3501,24 @@ isSupportWideGamut(callback: AsyncCallback&lt;boolean&gt;): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------- | -- | -------------------------------------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:** **示例:**
```js ```js
windowClass.isSupportWideGamut((err, data) => { windowClass.isWindowSupportWideGamut((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data));
}) });
``` ```
### isSupportWideGamut<sup>8+</sup> ### isWindowSupportWideGamut<sup>9+</sup>
isSupportWideGamut(): Promise&lt;boolean&gt; isWindowSupportWideGamut(): Promise&lt;boolean&gt;
判断当前窗口是否支持广色域模式,使用Promise异步回调。 判断当前窗口是否支持广色域模式,使用Promise异步回调。
...@@ -2398,13 +3527,13 @@ isSupportWideGamut(): Promise&lt;boolean&gt; ...@@ -2398,13 +3527,13 @@ isSupportWideGamut(): Promise&lt;boolean&gt;
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------- | ------------------------------------------------------------ | | ---------------------- | ------------------------------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 | | Promise&lt;boolean&gt; | Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式。 |
**示例:** **示例:**
```js ```js
let promise = windowClass.isSupportWideGamut(); let promise = windowClass.isWindowSupportWideGamut();
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)); console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
...@@ -2412,12 +3541,15 @@ promise.then((data)=> { ...@@ -2412,12 +3541,15 @@ promise.then((data)=> {
}); });
``` ```
### setColorSpace<sup>8+</sup> ### setColorSpace<sup>(deprecated)</sup>
setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。 设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2439,12 +3571,15 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { ...@@ -2439,12 +3571,15 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => {
}) })
``` ```
### setColorSpace<sup>8+</sup> ### setColorSpace<sup>(deprecated)</sup>
setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt; setColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。 设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[setWindowColorSpace()](#setwindowcolorspace9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2470,12 +3605,81 @@ promise.then((data)=> { ...@@ -2470,12 +3605,81 @@ promise.then((data)=> {
}); });
``` ```
### getColorSpace<sup>8+</sup> ### setWindowColorSpace<sup>9+</sup>
setWindowColorSpace(colorSpace:ColorSpace, callback: AsyncCallback&lt;void&gt;): void
设置当前窗口为广色域模式或默认色域模式,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | -- | ----------- |
| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```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));
};
```
### setWindowColorSpace<sup>9+</sup>
setWindowColorSpace(colorSpace:ColorSpace): Promise&lt;void&gt;
设置当前窗口为广色域模式或默认色域模式,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | -- | ------------- |
| colorSpace | [ColorSpace](#colorspace) | 是 | 设置色域模式。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
try {
let promise = windowClass.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT);
promise.then((data)=> {
console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set window colorspace. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception));
};
```
### getColorSpace<sup>(deprecated)</sup>
getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void getColorSpace(callback: AsyncCallback&lt;ColorSpace&gt;): void
获取当前窗口色域模式,使用callback异步回调。 获取当前窗口色域模式,使用callback异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2496,12 +3700,15 @@ windowClass.getColorSpace((err, data) => { ...@@ -2496,12 +3700,15 @@ windowClass.getColorSpace((err, data) => {
}) })
``` ```
### getColorSpace<sup>8+</sup> ### getColorSpace<sup>(deprecated)</sup>
getColorSpace(): Promise&lt;ColorSpace&gt; getColorSpace(): Promise&lt;ColorSpace&gt;
获取当前窗口色域模式,使用Promise异步回调。 获取当前窗口色域模式,使用Promise异步回调。
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃,推荐使用[getWindowColorSpace()](#getwindowcolorspace9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:** **返回值:**
...@@ -2521,12 +3728,35 @@ promise.then((data)=> { ...@@ -2521,12 +3728,35 @@ promise.then((data)=> {
}); });
``` ```
### setBackgroundColor ### getWindowColorSpace<sup>9+</sup>
getWindowColorSpace(): ColorSpace
获取当前窗口色域模式。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------- |
| [ColorSpace](#colorspace) | 当前色域模式。 |
**示例:**
```js
let colorSpace = windowClass.getWindowColorSpace();
```
### setBackgroundColor<sup>(deprecated)</sup>
setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2549,12 +3779,15 @@ windowClass.setBackgroundColor(color, (err, data) => { ...@@ -2549,12 +3779,15 @@ windowClass.setBackgroundColor(color, (err, data) => {
}); });
``` ```
### setBackgroundColor ### setBackgroundColor<sup>(deprecated)</sup>
setBackgroundColor(color: string): Promise&lt;void&gt; setBackgroundColor(color: string): Promise&lt;void&gt;
设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。 设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBackgroundColor()](#setwindowbackgroundcolor9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2581,35 +3814,40 @@ promise.then((data)=> { ...@@ -2581,35 +3814,40 @@ promise.then((data)=> {
}); });
``` ```
### setWakeUpScreen()<sup>9+</sup> ### setWindowBackgroundColor<sup>9+</sup>
setWakeUpScreen(wakeUp: boolean): void;
窗口唤醒屏幕。 setWindowBackgroundColor(color: string): void
**系统接口:** 此接口为系统接口 设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)之后使用
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------------- | ------- | ---- | ---------------------------- | | ----- | ------ | -- | ----------------------------------------------------------------------- |
| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 | | color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
**示例:** **示例:**
```js ```js
let wakeUp = true; let color = '#00ff33';
windowClass.setWakeUpScreen(wakeUp); try {
windowClass.setWindowBackgroundColor(color);
} catch (exception) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception));
};
``` ```
### setBrightness ### setBrightness<sup>(deprecated)</sup>
setBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void setBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void
设置屏幕亮度值,使用callback异步回调。 设置屏幕亮度值,使用callback异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2632,12 +3870,15 @@ windowClass.setBrightness(brightness, (err, data) => { ...@@ -2632,12 +3870,15 @@ windowClass.setBrightness(brightness, (err, data) => {
}); });
``` ```
### setBrightness ### setBrightness<sup>(deprecated)</sup>
setBrightness(brightness: number): Promise&lt;void&gt; setBrightness(brightness: number): Promise&lt;void&gt;
设置屏幕亮度值,使用Promise异步回调。 设置屏幕亮度值,使用Promise异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowBrightness()](#setwindowbrightness9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2664,6 +3905,74 @@ promise.then((data)=> { ...@@ -2664,6 +3905,74 @@ promise.then((data)=> {
}); });
``` ```
### setWindowBrightness<sup>9+</sup>
setWindowBrightness(brightness: number, callback: AsyncCallback&lt;void&gt;): void
设置屏幕亮度值,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | -- | --------------------------------- |
| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```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));
};
```
### setWindowBrightness<sup>9+</sup>
setWindowBrightness(brightness: number): Promise&lt;void&gt;
设置屏幕亮度值,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | -- | --------------------------------- |
| brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let brightness = 1;
try {
let promise = windowClass.setWindowBrightness(brightness);
promise.then((data)=> {
console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception));
};
```
### setDimBehind<sup>(deprecated)</sup> ### setDimBehind<sup>(deprecated)</sup>
setDimBehind(dimBehindValue: number, callback: AsyncCallback&lt;void&gt;): void setDimBehind(dimBehindValue: number, callback: AsyncCallback&lt;void&gt;): void
...@@ -2730,9 +4039,75 @@ promise.then((data)=> { ...@@ -2730,9 +4039,75 @@ promise.then((data)=> {
}); });
``` ```
### setFocusable<sup>7+</sup> ### setFocusable<sup>(deprecated)</sup>
setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
设置点击时是否支持切换焦点窗口,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | ---------------------------- |
| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```js
let isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
});
```
### setFocusable<sup>(deprecated)</sup>
setFocusable(isFocusable: boolean): Promise&lt;void&gt;
设置点击时是否支持切换焦点窗口,使用Promise异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowFocusable()](#setwindowfocusable9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------- | ---- | ---------------------------- |
| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```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));
}).catch((err)=>{
console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
});
```
### setWindowFocusable<sup>9+</sup>
setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void setWindowFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
设置点击时是否支持切换焦点窗口,使用callback异步回调。 设置点击时是否支持切换焦点窗口,使用callback异步回调。
...@@ -2741,7 +4116,7 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -2741,7 +4116,7 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | ---------------------------- | | ----------- | ------------------------- | -- | -------------------------- |
| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
...@@ -2749,18 +4124,22 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -2749,18 +4124,22 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback&lt;void&gt;): void
```js ```js
let isFocusable= true; let isFocusable= true;
windowClass.setFocusable(isFocusable, (err, data) => { try {
windowClass.setWindowFocusable(isFocusable, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); 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));
};
``` ```
### setFocusable<sup>7+</sup> ### setWindowFocusable<sup>9+</sup>
setFocusable(isFocusable: boolean): Promise&lt;void&gt; setWindowFocusable(isFocusable: boolean): Promise&lt;void&gt;
设置点击时是否支持切换焦点窗口,使用Promise异步回调。 设置点击时是否支持切换焦点窗口,使用Promise异步回调。
...@@ -2769,33 +4148,40 @@ setFocusable(isFocusable: boolean): Promise&lt;void&gt; ...@@ -2769,33 +4148,40 @@ setFocusable(isFocusable: boolean): Promise&lt;void&gt;
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------- | ---- | ---------------------------- | | ----------- | ------- | -- | -------------------------- |
| isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------------------- | | ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
let isFocusable= true; let isFocusable= true;
let promise = windowClass.setFocusable(isFocusable); try {
promise.then((data)=> { let promise = windowClass.setWindowFocusable(isFocusable);
promise.then((data)=> {
console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err));
}); });
} catch (exception) {
console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception));
};
``` ```
### setKeepScreenOn ### setKeepScreenOn<sup>(deprecated)</sup>
setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void
设置屏幕是否为常亮状态,使用callback异步回调。 设置屏幕是否为常亮状态,使用callback异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2818,12 +4204,15 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { ...@@ -2818,12 +4204,15 @@ windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => {
}); });
``` ```
### setKeepScreenOn ### setKeepScreenOn<sup>(deprecated)</sup>
setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt; setKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
设置屏幕是否为常亮状态,使用Promise异步回调。 设置屏幕是否为常亮状态,使用Promise异步回调。
> **说明:**
> 从 API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowKeepScreenOn()](#setwindowkeepscreenon9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2850,6 +4239,101 @@ promise.then((data) => { ...@@ -2850,6 +4239,101 @@ promise.then((data) => {
}); });
``` ```
### setWindowKeepScreenOn<sup>9+</sup>
setWindowKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback&lt;void&gt;): void
设置屏幕是否为常亮状态,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------- | -- | ---------------------- |
| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:**
```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));
};
```
### setWindowKeepScreenOn<sup>9+</sup>
setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise&lt;void&gt;
设置屏幕是否为常亮状态,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------- | -- | ---------------------- |
| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:**
```js
let isKeepScreenOn = true;
try {
let promise = windowClass.setWindowKeepScreenOn(isKeepScreenOn);
promise.then((data) => {
console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.info('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception));
};
```
### setWakeUpScreen()<sup>9+</sup>
setWakeUpScreen(wakeUp: boolean): void;
窗口唤醒屏幕。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------------- | ------- | ---- | ---------------------------- |
| wakeUp | boolean | 是 | 是否设置唤醒屏幕。 |
**示例:**
```js
let wakeUp = true;
try {
windowClass.setWakeUpScreen(wakeUp);
} catch (exception) {
console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
};
```
### setOutsideTouchable<sup>(deprecated)</sup> ### setOutsideTouchable<sup>(deprecated)</sup>
setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void setOutsideTouchable(touchable: boolean, callback: AsyncCallback&lt;void&gt;): void
...@@ -2916,12 +4400,15 @@ promise.then((data)=> { ...@@ -2916,12 +4400,15 @@ promise.then((data)=> {
}); });
``` ```
### setPrivacyMode<sup>7+</sup> ### setPrivacyMode<sup>(deprecated)</sup>
setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2945,12 +4432,15 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { ...@@ -2945,12 +4432,15 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => {
}); });
``` ```
### setPrivacyMode<sup>7+</sup> ### setPrivacyMode<sup>(deprecated)</sup>
setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt; setPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowPrivacyMode()](#setwindowprivacymode9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -2977,91 +4467,78 @@ promise.then((data)=> { ...@@ -2977,91 +4467,78 @@ promise.then((data)=> {
}); });
``` ```
### setSnapshotSkip<sup>9+</sup> ### setWindowPrivacyMode<sup>9+</sup>
setSnapshotSkip(isSkip: boolean): void
截屏录屏是否忽略当前窗口。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------- | ---- | -------------------- |
| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。<br>true表示忽略当前窗口,false表示不忽略当前窗口。</br> |
```js
let isSkip = true;
windowClass.setSnapshotSkip(isSkip);
```
### setTouchable<sup>7+</sup>
setTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口是否为可触状态,使用callback异步回调 设置窗口是否为隐私模式,使用callback异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | -------------------- | | ------------- | ------------------------- | -- | ------------------ |
| isTouchable | boolean | 是 | 窗口是否为可触状态。 | | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
let isTouchable = true; let isPrivacyMode = true;
windowClass.setTouchable(isTouchable, (err, data) => { try {
windowClass.setWindowPrivacyMode(isPrivacyMode, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); 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));
};
``` ```
### setTouchable<sup>7+</sup> ### setWindowPrivacyMode<sup>9+</sup>
setTouchable(isTouchable: boolean): Promise&lt;void&gt; setWindowPrivacyMode(isPrivacyMode: boolean): Promise&lt;void&gt;
设置窗口是否为可触状态,使用Promise异步回调 设置窗口是否为隐私模式,使用Promise异步回调。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------- | ---- | -------------------- | | ------------- | ------- | -- | ------------------ |
| isTouchable | boolean | 是 | 窗口是否为可触状态。 | | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------- | ------------------------- | | ------------------- | ------------------------ |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
let isTouchable = true; let isPrivacyMode = true;
let promise = windowClass.setTouchable(isTouchable); try {
promise.then((data)=> { let promise = windowClass.setWindowPrivacyMode(isPrivacyMode);
console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)); promise.then((data)=> {
}).catch((err)=>{ console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data));
console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); }).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));
};
``` ```
### setForbidSplitMove<sup>9+</sup> ### setSnapshotSkip<sup>9+</sup>
setSnapshotSkip(isSkip: boolean): void
setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口在分屏模式下是否被禁止移动,使用callback异步回调 截屏录屏是否忽略当前窗口
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -3069,32 +4546,59 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&g ...@@ -3069,32 +4546,59 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&g
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------- | ---- | -------------------- |
| isSkip | boolean | 是 | 截屏录屏是否忽略当前窗口,默认为false。<br>true表示忽略当前窗口,false表示不忽略当前窗口。</br> |
```js
let isSkip = true;
try {
windowClass.setSnapshotSkip(isSkip);
} catch (exception) {
console.error('Failed to Skip. Cause: ' + JSON.stringify(exception));
};
```
### setTouchable<sup>(deprecated)</sup>
setTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口是否为可触状态,使用callback异步回调。
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | -------------------- | | ----------- | ------------------------- | ---- | -------------------- |
| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | | isTouchable | boolean | 是 | 窗口是否为可触状态。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
let isForbidSplitMove = true; let isTouchable = true;
windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => { windowClass.setTouchable(isTouchable, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data)); console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
}); });
``` ```
### setForbidSplitMove<sup>9+</sup> ### setTouchable<sup>(deprecated)</sup>
setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt; setTouchable(isTouchable: boolean): Promise&lt;void&gt;
设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。 设置窗口是否为可触状态,使用Promise异步回调。
**系统接口:** 此接口为系统接口。 > **说明:**
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowTouchable()](#setwindowtouchable9-1)。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
...@@ -3102,7 +4606,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt; ...@@ -3102,7 +4606,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------- | ---- | -------------------- | | ----------- | ------- | ---- | -------------------- |
| isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 | | isTouchable | boolean | 是 | 窗口是否为可触状态。 |
**返回值:** **返回值:**
...@@ -3113,95 +4617,88 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt; ...@@ -3113,95 +4617,88 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
let isForbidSplitMove = true; let isTouchable = true;
let promise = windowClass.setForbidSplitMove(isForbidSplitMove); let promise = windowClass.setTouchable(isTouchable);
promise.then((data)=> { promise.then((data)=> {
console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data)); console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
}); });
``` ```
### snapshot<sup>9+</sup> ### setWindowTouchable<sup>9+</sup>
snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void setWindowTouchable(isTouchable: boolean, callback: AsyncCallback&lt;void&gt;): void
获取窗口截图,使用callback异步回调。 设置窗口是否为可触状态,使用callback异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | -------------------- | | ----------- | ------------------------- | -- | ------------------ |
| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | 是 | 回调函数。 | | isTouchable | boolean | 是 | 窗口是否为可触状态。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
windowClass.snapshot((err, data) => { let isTouchable = true;
try {
windowClass.setWindowTouchable(isTouchable, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data));
data.release(); // PixelMap使用完后及时释放内存 });
}); } catch (exception) {
``` console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
### snapshot<sup>9+</sup>
snapshot(): Promise&lt;image.PixelMap&gt;
获取窗口截图,使用Promise异步回调。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise对象。返回当前窗口截图。 |
**示例:**
```js
let promise = windowClass.snapshot();
promise.then((pixelMap)=> {
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
pixelMap.release(); // PixelMap使用完后及时释放内存
}).catch((err)=>{
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
});
``` ```
### setBlur<sup>9+</sup> ### setWindowTouchable<sup>9+</sup>
setBlur(radius: number): void
设置窗口模糊。 setWindowTouchable(isTouchable: boolean): Promise&lt;void&gt;
**系统接口:** 此接口为系统接口 设置窗口是否为可触状态,使用Promise异步回调
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------- | -- | ------------------- |
| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 | | isTouchable | boolean | 是 | 窗口是否为可触状态。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
windowClass.setBlur(4.0); let isTouchable = true;
try {
let promise = windowClass.setWindowTouchable(isTouchable);
promise.then((data)=> {
console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception));
};
``` ```
### setBackdropBlur<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
setBackdropBlur(radius: number): void setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
设置窗口背景模糊 设置窗口在分屏模式下是否被禁止移动,使用callback异步回调
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -3210,20 +4707,32 @@ setBackdropBlur(radius: number): void ...@@ -3210,20 +4707,32 @@ setBackdropBlur(radius: number): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------------------------- | ---- | -------------------- |
| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 | | isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
```js ```js
windowClass.setBackdropBlur(4.0); let isForbidSplitMove = true;
try {
windowClass.setForbidSplitMove(isForbidSplitMove, (err, data) => {
if (err.code) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in forbidding window moving in split screen mode. Data:' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
``` ```
### setBackdropBlurStyle<sup>9+</sup> ### setForbidSplitMove<sup>9+</sup>
setBackdropBlurStyle(blurStyle: BlurStyle): void setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
设置窗口背景模糊类型 设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
...@@ -3232,60 +4741,82 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void ...@@ -3232,60 +4741,82 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | --------- | ---- | ---------------------- | | ----------- | ------- | ---- | -------------------- |
| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 | | isForbidSplitMove | boolean | 是 | 窗口在分屏模式下是否被禁止移动。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**示例:** **示例:**
```js ```js
windowClass.setBackdropBlurStyle(window.BlurType.THIN); let isForbidSplitMove = true;
try {
let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
promise.then((data)=> {
console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
};
``` ```
### setShadow<sup>9+</sup> ### snapshot<sup>9+</sup>
setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
设置窗口边缘阴影。 snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void
**系统接口:** 此接口为系统接口 获取窗口截图,使用callback异步回调
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------------------------- | ---- | -------------------- |
| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 | | callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | 是 | 回调函数。 |
| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 |
| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 |
**示例:** **示例:**
```js ```js
windowClass.setShadow(4.0, '#FF00FF00', 2, 3); windowClass.snapshot((err, data) => {
if (err.code) {
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
data.release(); // PixelMap使用完后及时释放内存
});
``` ```
### setCornerRadius<sup>9+</sup> ### snapshot<sup>9+</sup>
setCornerRadius(cornerRadius: number): void
设置窗口圆角半径。 snapshot(): Promise&lt;image.PixelMap&gt;
**系统接口:** 此接口为系统接口 获取窗口截图,使用Promise异步回调
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **返回值:**
| 参数名 | 类型 | 必填 | 说明 | | 类型 | 说明 |
| ----------- | ------- | ---- | -------------------- | | ------------------- | ------------------------- |
| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 | | Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise对象。返回当前窗口截图。 |
**示例:** **示例:**
```js ```js
windowClass.setCornerRadius(4.0); let promise = windowClass.snapshot();
promise.then((pixelMap)=> {
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
pixelMap.release(); // PixelMap使用完后及时释放内存
}).catch((err)=>{
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
});
``` ```
### opacity<sup>9+</sup> ### opacity<sup>9+</sup>
...@@ -3307,7 +4838,11 @@ opacity(opacity: number): void ...@@ -3307,7 +4838,11 @@ opacity(opacity: number): void
**示例:** **示例:**
```js ```js
windowClass.opacity(0.5); try {
windowClass.opacity(0.5);
} catch (exception) {
console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
};
``` ```
### scale<sup>9+</sup> ### scale<sup>9+</sup>
...@@ -3335,7 +4870,11 @@ let obj : window.ScaleOptions = { ...@@ -3335,7 +4870,11 @@ let obj : window.ScaleOptions = {
pivotX = 0.5; pivotX = 0.5;
pivotY = 0.5; pivotY = 0.5;
} }
windowClass.scale(obj); try {
windowClass.scale(obj);
} catch (exception) {
console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
};
``` ```
### rotate<sup>9+</sup> ### rotate<sup>9+</sup>
...@@ -3364,7 +4903,11 @@ let obj : window.RotateOptions = { ...@@ -3364,7 +4903,11 @@ let obj : window.RotateOptions = {
pivotX = 0.5; pivotX = 0.5;
pivotY = 0.5; pivotY = 0.5;
} }
windowClass.rotate(obj); try {
windowClass.rotate(obj);
} catch (exception) {
console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
};
``` ```
### translate<sup>9+</sup> ### translate<sup>9+</sup>
...@@ -3391,7 +4934,11 @@ let obj : window.TranslateOptions = { ...@@ -3391,7 +4934,11 @@ let obj : window.TranslateOptions = {
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} }
windowClass.translate(obj); try {
windowClass.translate(obj);
} catch (exception) {
console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
};
``` ```
### getTransitionController<sup>9+</sup> ### getTransitionController<sup>9+</sup>
...@@ -3447,6 +4994,139 @@ windowClass.hideWithAnimation((err, data) => { ...@@ -3447,6 +4994,139 @@ windowClass.hideWithAnimation((err, data) => {
}) })
``` ```
### setBlur<sup>9+</sup>
setBlur(radius: number): void
设置窗口模糊。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| radius | number | 是 | 表示窗口模糊的半径值,取值范围为大于等于0,0表示关闭窗口模糊。 |
**示例:**
```js
try {
windowClass.setBlur(4.0);
} catch (exception) {
console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
};
```
### setBackdropBlur<sup>9+</sup>
setBackdropBlur(radius: number): void
设置窗口背景模糊。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| radius | number | 是 | 表示窗口背景模糊的半径值,取值范围为大于等于0,0表示关闭窗口背景模糊。 |
**示例:**
```js
try {
windowClass.setBackdropBlur(4.0);
} catch (exception) {
console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
};
```
### setBackdropBlurStyle<sup>9+</sup>
setBackdropBlurStyle(blurStyle: BlurStyle): void
设置窗口背景模糊类型。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | --------- | ---- | ---------------------- |
| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗口背景模糊类型。 |
**示例:**
```js
try {
windowClass.setBackdropBlurStyle(window.BlurType.THIN);
} catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
};
```
### setShadow<sup>9+</sup>
setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
设置窗口边缘阴影。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------------------------------------------------ |
| radius | number | 是 | 表示窗口边缘阴影的模糊半径,取值范围为大于等于0,0表示关闭窗口边缘阴影。 |
| color | string | 否 | 表示窗口边缘阴影的颜色,为十六进制颜色,不区分大小写,例如`#00FF00``#FF00FF00`。 |
| offsetX | number | 否 | 表示窗口边缘阴影的X轴的偏移量,单位为px。 |
| offsetY | number | 否 | 表示窗口边缘阴影的Y轴的偏移量,单位为px。 |
**示例:**
```js
try {
windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
} catch (exception) {
console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
};
```
### setCornerRadius<sup>9+</sup>
setCornerRadius(cornerRadius: number): void
设置窗口圆角半径。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------- | ---- | -------------------- |
| radius | number | 是 | 表示窗口圆角的半径值,取值范围为大于等于0,0表示没有窗口圆角。 |
**示例:**
```js
try {
windowClass.setCornerRadius(4.0);
} catch (exception) {
console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
};
```
## WindowStageEventType<sup>9+</sup> ## WindowStageEventType<sup>9+</sup>
WindowStage生命周期。 WindowStage生命周期。
...@@ -3503,6 +5183,7 @@ class myAbility extends Ability { ...@@ -3503,6 +5183,7 @@ class myAbility extends Ability {
} }
} }
``` ```
### getMainWindow<sup>9+</sup> ### getMainWindow<sup>9+</sup>
getMainWindow(): Promise&lt;Window&gt; getMainWindow(): Promise&lt;Window&gt;
...@@ -3537,6 +5218,39 @@ class myAbility extends Ability { ...@@ -3537,6 +5218,39 @@ class myAbility extends Ability {
} }
} }
``` ```
### getMainWindowSync<sup>9+</sup>
getMainWindow(): Window;
获取该WindowStage实例下的主窗口。
**模型约束:** 此接口仅可在Stage模型下使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ----------------- | --------------------------------- |
| [Window](#window) | 返回当前WindowStage下的主窗口对象。 |
**示例:**
```ts
import Ability from '@ohos.application.Ability';
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
try {
let windowClass = windowStage.getMainWindowSync();
} catch (exception) {
console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception));
};
}
}
```
### createSubWindow<sup>9+</sup> ### createSubWindow<sup>9+</sup>
createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void createSubWindow(name: string, callback: AsyncCallback&lt;Window&gt;): void
...@@ -3562,6 +5276,7 @@ class myAbility extends Ability { ...@@ -3562,6 +5276,7 @@ class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try {
windowStage.createSubWindow('mySubWindow', (err, data) => { windowStage.createSubWindow('mySubWindow', (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
...@@ -3571,6 +5286,9 @@ class myAbility extends Ability { ...@@ -3571,6 +5286,9 @@ class myAbility extends Ability {
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
windowClass.resetSize(500, 1000); windowClass.resetSize(500, 1000);
}); });
} catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3604,16 +5322,21 @@ class myAbility extends Ability { ...@@ -3604,16 +5322,21 @@ class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try {
let promise = windowStage.createSubWindow('mySubWindow'); let promise = windowStage.createSubWindow('mySubWindow');
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
}) });
} catch (exception) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception));
};
} }
} }
``` ```
### getSubWindow<sup>9+</sup> ### getSubWindow<sup>9+</sup>
getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void getSubWindow(callback: AsyncCallback&lt;Array&lt;Window&gt;&gt;): void
...@@ -3711,6 +5434,7 @@ class myAbility extends Ability { ...@@ -3711,6 +5434,7 @@ class myAbility extends Ability {
this.storage = new LocalStorage(); this.storage = new LocalStorage();
this.storage.setOrCreate('storageSimpleProp',121); this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.loadContent('pages/page2',this.storage,(err, data) => { windowStage.loadContent('pages/page2',this.storage,(err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
...@@ -3718,6 +5442,9 @@ class myAbility extends Ability { ...@@ -3718,6 +5442,9 @@ class myAbility extends Ability {
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3756,13 +5483,17 @@ class myAbility extends Ability { ...@@ -3756,13 +5483,17 @@ class myAbility extends Ability {
this.storage.setOrCreate('storageSimpleProp',121); this.storage.setOrCreate('storageSimpleProp',121);
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
let windowClass = null; let windowClass = null;
try {
let promise = windowStage.loadContent('pages/page2',this.storage); let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
}) });
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3791,6 +5522,7 @@ import Ability from '@ohos.application.Ability'; ...@@ -3791,6 +5522,7 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.loadContent('pages/page2', (err, data) => { windowStage.loadContent('pages/page2', (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
...@@ -3798,6 +5530,9 @@ class myAbility extends Ability { ...@@ -3798,6 +5530,9 @@ class myAbility extends Ability {
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3826,9 +5561,15 @@ import Ability from '@ohos.application.Ability'; ...@@ -3826,9 +5561,15 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.on('windowStageEvent', (data) => { windowStage.on('windowStageEvent', (data) => {
console.info('Succeeded in enabling the listener for window stage event changes. Data: ' + JSON.stringify(data)); console.info('Succeeded in enabling the listener for window stage event changes. Data: ' +
JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to enable the listener for window stage event changes. Cause:' +
JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3857,7 +5598,12 @@ import Ability from '@ohos.application.Ability'; ...@@ -3857,7 +5598,12 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.off('windowStageEvent'); windowStage.off('windowStageEvent');
} catch (exception) {
console.error('Failed to disable the listener for window stage event changes. Cause:' +
JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3911,7 +5657,11 @@ import Ability from '@ohos.application.Ability'; ...@@ -3911,7 +5657,11 @@ import Ability from '@ohos.application.Ability';
class myAbility extends Ability { class myAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate'); console.log('onWindowStageCreate');
try {
windowStage.setShowOnLockScreen(true); windowStage.setShowOnLockScreen(true);
} catch (exception) {
console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
};
} }
} }
``` ```
...@@ -3968,9 +5718,13 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -3968,9 +5718,13 @@ controller.animationForShown = (context : window.TransitionContext) => {
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
) )
try {
context.completeTransition(true) context.completeTransition(true)
} catch (exception) {
console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
}
console.info('complete transition end'); console.info('complete transition end');
} };
``` ```
## TransitionController<sup>9+</sup> ## TransitionController<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册