Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a60db391
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a60db391
编写于
6月 14, 2022
作者:
G
ge-yafang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
ge-yafang
<
geyafang@huawei.com
>
上级
c4c5604d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
1231 addition
and
1040 deletion
+1231
-1040
zh-cn/application-dev/reference/apis/js-apis-window.md
zh-cn/application-dev/reference/apis/js-apis-window.md
+1231
-1040
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-window.md
浏览文件 @
a60db391
# 窗口
# 窗口
窗口提供管理窗口的一些基础能力,包括对窗口的创建、销毁,以及对窗口的属性设置等各项功能。
窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。
该模块提供以下窗口相关的常用功能:
-
[
Window
](
#window
)
:当前窗口实例,窗口管理器管理的基本单元。
-
[
WindowStage
](
#windowstage9
)
:窗口管理器。管理各个基本窗口单元。
> **说明:**
> **说明:**
>
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
## 导入模块
...
@@ -14,67 +19,67 @@ import window from '@ohos.window';
...
@@ -14,67 +19,67 @@ import window from '@ohos.window';
## WindowType<sup>7+</sup>
## WindowType<sup>7+</sup>
窗口类型。
窗口类型
枚举
。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 |
默认
值 | 说明 |
| 名称 | 值 | 说明 |
| ----------------- | ------ | ------------------ |
| ----------------- | ------ | ------------------ |
| TYPE_APP | 0 | 表示应用子窗口。
|
| TYPE_APP | 0 | 表示应用子窗口。
此接口仅可在FA模型下使用。
|
| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。 |
| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。
此接口仅可在Stage模型下使用。
|
| TYPE_INPUT_METHOD
<sup>
9+
</sup>
| 2 | 表示输入法窗口。 |
| TYPE_INPUT_METHOD
<sup>
9+
</sup>
| 2 | 表示输入法窗口。
此接口仅可在Stage模型下使用。
<br>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_STATUS_BAR
<sup>
9+
</sup>
| 3 | 表示状态栏窗口。 |
| TYPE_STATUS_BAR
<sup>
9+
</sup>
| 3 | 表示状态栏窗口。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_PANEL
<sup>
9+
</sup>
| 4 | 表示通知栏。 |
| TYPE_PANEL
<sup>
9+
</sup>
| 4 | 表示通知栏。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_KEYGUARD
<sup>
9+
</sup>
| 5 | 表示锁屏。 |
| TYPE_KEYGUARD
<sup>
9+
</sup>
| 5 | 表示锁屏。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_VOLUME_OVERLAY
<sup>
9+
</sup>
| 6 | 表示音量条。 |
| TYPE_VOLUME_OVERLAY
<sup>
9+
</sup>
| 6 | 表示音量条。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_NAVIGATION_BAR
<sup>
9+
</sup>
| 7 | 表示导航栏窗口。 |
| TYPE_NAVIGATION_BAR
<sup>
9+
</sup>
| 7 | 表示导航栏窗口。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_FLOAT
<sup>
9+
</sup>
| 8 | 表示悬浮窗。 |
| TYPE_FLOAT
<sup>
9+
</sup>
| 8 | 表示悬浮窗。
此接口仅可在Stage模型下使用。
<br>
**需要权限:**
ohos.permission.SYSTEM_FLOAT_WINDOW
|
| TYPE_WALLPAPER
<sup>
9+
</sup>
| 9 | 表示壁纸。 |
| TYPE_WALLPAPER
<sup>
9+
</sup>
| 9 | 表示壁纸。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_DESKTOP
<sup>
9+
</sup>
| 10 | 表示桌面。 |
| TYPE_DESKTOP
<sup>
9+
</sup>
| 10 | 表示桌面。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_LAUNCHER_RECENT
<sup>
9+
</sup>
| 11 | 表示多任务中心。 |
| TYPE_LAUNCHER_RECENT
<sup>
9+
</sup>
| 11 | 表示多任务中心。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_LAUNCHER_DOCK
<sup>
9+
</sup>
| 12 | 表示桌面Dock栏。 |
| TYPE_LAUNCHER_DOCK
<sup>
9+
</sup>
| 12 | 表示桌面Dock栏。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_VOICE_INTERACTION
<sup>
9+
</sup>
| 13 | 表示智慧语音。 |
| TYPE_VOICE_INTERACTION
<sup>
9+
</sup>
| 13 | 表示智慧语音。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
| TYPE_POINTER
<sup>
9+
</sup>
| 14 | 表示鼠标。 |
| TYPE_POINTER
<sup>
9+
</sup>
| 14 | 表示鼠标。
此接口仅可在Stage模型下使用。
<br/>
此接口为系统接口,三方应用不支持调用。
|
## AvoidAreaType<sup>7+</sup>
## AvoidAreaType<sup>7+</sup>
窗口内容需要规避区域的类型。
窗口内容需要规避区域的类型
枚举
。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 |
默认值
| 说明 |
| 名称 |
值
| 说明 |
| ----------- | ----
--
| ------------------ |
| ----------- | ---- | ------------------ |
| TYPE_SYSTEM | 0
| 表示系统默认区域。 |
| TYPE_SYSTEM | 0 | 表示系统默认区域。 |
| TYPE_CUTOUT | 1
| 表示刘海屏区域。 |
| TYPE_CUTOUT | 1 | 表示刘海屏区域。 |
## WindowMode<sup>7+</sup>
## WindowMode<sup>7+</sup>
窗口模式。
窗口模式
枚举
。
此接口为系统接口,三方应用不支持调用。
此接口为系统接口,三方应用不支持调用。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 |
默认值
| 说明 |
| 名称 |
值
| 说明 |
| ---------- | ----
--
| ----------------------------- |
| ---------- | ---- | ----------------------------- |
| UNDEFINED | 1
| 表示APP未定义窗口模式。 |
| UNDEFINED | 1 | 表示APP未定义窗口模式。 |
| FULLSCREEN | 2
| 表示APP全屏模式。 |
| FULLSCREEN | 2 | 表示APP全屏模式。 |
| PRIMARY | 3
| 表示APP分屏多窗口主要模式。 |
| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 |
| SECONDARY | 4
| 表示APP分屏多窗口次要模式。 |
| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 |
| FLOATING | 5
| 表示APP自由悬浮形式窗口模式。 |
| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 |
## SystemBarProperties
## SystemBarProperties
状态栏导航栏的属性。
状态栏
、
导航栏的属性。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
| -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ |
| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
"
\#
00FF00"或"
\#
FF00FF00"
。 |
| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
`#00FF00`
或
`#FF00FF00`
。 |
| isStatusBarLightIcon
<sup>
7+
</sup>
| boolean | 否 | 是 | 状态栏图标是否为高亮状态。 |
| isStatusBarLightIcon
<sup>
7+
</sup>
| boolean | 否 | 是 | 状态栏图标是否为高亮状态。 |
| statusBarContentColor
<sup>
8+
</sup>
| string | 否 | 是 | 状态栏文字颜色。 |
| statusBarContentColor
<sup>
8+
</sup>
| string | 否 | 是 | 状态栏文字颜色。 |
| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
"
\#
00FF00"或"
\#
FF00FF00"
。 |
| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
`#00FF00`
或
`#FF00FF00`
。 |
| isNavigationBarLightIcon
<sup>
7+
</sup>
| boolean | 否 | 否 | 导航栏图标是否为高亮状态。 |
| isNavigationBarLightIcon
<sup>
7+
</sup>
| boolean | 否 | 否 | 导航栏图标是否为高亮状态。 |
| navigationBarContentColor
<sup>
8+
</sup>
| string | 否 | 是 | 导航栏文字颜色。 |
| navigationBarContentColor
<sup>
8+
</sup>
| string | 否 | 是 | 导航栏文字颜色。 |
...
@@ -84,14 +89,14 @@ import window from '@ohos.window';
...
@@ -84,14 +89,14 @@ import window from '@ohos.window';
此接口为系统接口,三方应用不支持调用。
此接口为系统接口,三方应用不支持调用。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
| type |
[
WindowType
](
#windowtype
)
| 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| type |
[
WindowType
](
#windowtype
)
| 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 |
| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 |
| region |
[
Rect
](
#rect
)
| 是 | 是 | 当前系统栏的位置及大小。 |
| region |
[
Rect
](
#rect
)
| 是 | 是 | 当前系统栏的位置及大小。 |
| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
"
\#
00FF00"或"
\#
FF00FF00"
。 |
| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如
`#00FF00`
或
`#FF00FF00`
。 |
| contentColor | string | 是 | 是 | 系统栏文字颜色。 |
| contentColor | string | 是 | 是 | 系统栏文字颜色。 |
## SystemBarTintState<sup>8+</sup>
## SystemBarTintState<sup>8+</sup>
...
@@ -100,18 +105,18 @@ import window from '@ohos.window';
...
@@ -100,18 +105,18 @@ import window from '@ohos.window';
此接口为系统接口,三方应用不支持调用。
此接口为系统接口,三方应用不支持调用。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明
|
| ---------- | --------------------------------------------------- | ---- | ---- | -------------------------- |
| ---------- | --------------------------------------------------- | ---- | ---- | --------------------------
--
|
| displayId | number | 是 | 否 | 当前物理屏幕id。 |
| displayId | number | 是 | 否 | 当前物理屏幕id。
|
| regionTint | Array
<
[
SystemBarRegionTint
](
#systembarregiontint8
)
>
| 是 | 是 | 当前
改变所有的
系统栏信息。 |
| regionTint | Array
<
[
SystemBarRegionTint
](
#systembarregiontint8
)
>
| 是 | 是 | 当前
已改变的所有
系统栏信息。 |
## Rect<sup>7+</sup>
## Rect<sup>7+</sup>
窗口矩形区域。
窗口矩形区域。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------ | -------- | ---- | ---- | ------------------ |
| ------ | -------- | ---- | ---- | ------------------ |
...
@@ -124,7 +129,7 @@ import window from '@ohos.window';
...
@@ -124,7 +129,7 @@ import window from '@ohos.window';
窗口内容规避区域。
窗口内容规避区域。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ---------- | ------------- | ---- | ---- | ------------------ |
| ---------- | ------------- | ---- | ---- | ------------------ |
...
@@ -137,7 +142,7 @@ import window from '@ohos.window';
...
@@ -137,7 +142,7 @@ import window from '@ohos.window';
窗口大小。
窗口大小。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------ | -------- | ---- | ---- | ---------- |
| ------ | -------- | ---- | ---- | ---------- |
...
@@ -148,7 +153,7 @@ import window from '@ohos.window';
...
@@ -148,7 +153,7 @@ import window from '@ohos.window';
窗口属性。
窗口属性。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
| ------------------------------- | ------------------------- | ---- | ---- | -------------------------------------------- |
...
@@ -169,7 +174,7 @@ import window from '@ohos.window';
...
@@ -169,7 +174,7 @@ import window from '@ohos.window';
色域模式。
色域模式。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 默认值 | 说明 |
| 名称 | 默认值 | 说明 |
| ---------- | ------ | -------------- |
| ---------- | ------ | -------------- |
...
@@ -182,32 +187,30 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi
...
@@ -182,32 +187,30 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi
创建子窗口,使用callback异步回调。
创建子窗口,使用callback异步回调。
从API version 8开始,此接口废弃,推荐使用
[
window.create<sup>8+</sup>
](
#windowcreate8
)
接口
。
此接口仅可在FA模型下使用
。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------------------------------------- | ---- | -------------------------- |
| -------- | -------------------------------------- | ---- | --------------------------
----------
|
| id | string | 是 | 窗口id。 |
| id | string | 是 | 窗口id。
|
| type |
[
WindowType
](
#windowtype
)
| 是 | 窗口类型。 |
| type |
[
WindowType
](
#windowtype
)
| 是 | 窗口类型。
|
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
返回
创建的子窗口对象。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
函数。返回当前
创建的子窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
window
.
create
(
"
first
"
,
window
.
WindowType
.
TYPE_APP
,
(
err
,
data
)
=>
{
let
promise
=
window
.
create
(
"
first
"
,
window
.
WindowType
.
TYPE_APP
);
if
(
err
.
code
)
{
promise
.
then
((
data
)
=>
{
console
.
error
(
'
Failed to create the subWindow. Cause:
'
+
JSON
.
stringify
(
err
));
windowClass
=
data
;
return
;
console
.
info
(
'
SubWindow created. Data:
'
+
JSON
.
stringify
(
data
));
}
}).
catch
((
err
)
=>
{
windowClass
=
data
;
console
.
error
(
'
Failed to create the subWindow. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
SubWindow created. Data:
'
+
JSON
.
stringify
(
data
))
});
windowClass
.
resetSize
(
500
,
1000
);
```
});
```
## window.create<sup>7+</sup>
## window.create<sup>7+</sup>
...
@@ -215,7 +218,7 @@ create(id: string, type: WindowType): Promise<Window>
...
@@ -215,7 +218,7 @@ create(id: string, type: WindowType): Promise<Window>
创建子窗口,使用Promise异步回调。
创建子窗口,使用Promise异步回调。
从API version 8开始,此接口废弃,推荐使用
[
window.create<sup>8+</sup>
](
#windowcreate8
)
接口
。
此接口仅可在FA模型下使用
。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -228,22 +231,22 @@ create(id: string, type: WindowType): Promise<Window>
...
@@ -228,22 +231,22 @@ create(id: string, type: WindowType): Promise<Window>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------- | ---------------------------------------
----------
|
| -------------------------------- | --------------------------------------- |
| Promise
<
[Window](#window)
>
|
以Promise形式返回结果,
返回当前创建的子窗口对象。 |
| Promise
<
[Window](#window)
>
|
Promise对象。
返回当前创建的子窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
let
promise
=
window
.
create
(
"
first
"
,
window
.
WindowType
.
TYPE_APP
);
let
promise
=
window
.
create
(
"
first
"
,
window
.
WindowType
.
TYPE_APP
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
SubWindow created. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
SubWindow created. 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
));
});
});
```
```
## window.create<sup>8+</sup>
## window.create<sup>8+</sup>
...
@@ -262,22 +265,22 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi
...
@@ -262,22 +265,22 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<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
](
#windowtype
)
| 是 | 窗口类型。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
返回当前窗口对象。
|
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
函数。返回当前创建的子窗口对象。
|
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
window
.
create
(
this
.
context
,
"
alertWindow
"
,
window
.
WindowType
.
TYPE_SYSTEM_ALERT
,
(
err
,
data
)
=>
{
window
.
create
(
this
.
context
,
"
alertWindow
"
,
window
.
WindowType
.
TYPE_SYSTEM_ALERT
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to create the Window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to create the Window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Window created. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window created. Data:
'
+
JSON
.
stringify
(
data
));
windowClass
.
resetSize
(
500
,
1000
);
windowClass
.
resetSize
(
500
,
1000
);
});
});
```
```
## window.create<sup>8+</sup>
## window.create<sup>8+</sup>
...
@@ -299,22 +302,22 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window>
...
@@ -299,22 +302,22 @@ create(ctx: Context, id: string, type: WindowType): Promise<Window>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------- | ---------------------------------------
--------
|
| -------------------------------- | --------------------------------------- |
| Promise
<
[Window](#window)
>
|
以Promise形式返回结果,返回当前创建的
窗口对象。 |
| Promise
<
[Window](#window)
>
|
Promise对象。返回当前创建的子
窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
let
promise
=
window
.
create
(
this
.
context
,
"
alertWindow
"
,
window
.
WindowType
.
TYPE_SYSTEM_ALERT
);
let
promise
=
window
.
create
(
this
.
context
,
"
alertWindow
"
,
window
.
WindowType
.
TYPE_SYSTEM_ALERT
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Window created. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window created. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create the Window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to create the Window. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
## window.find<sup>7+</sup>
## window.find<sup>7+</sup>
...
@@ -326,24 +329,24 @@ find(id: string, callback: AsyncCallback<Window>): void
...
@@ -326,24 +329,24 @@ find(id: string, callback: AsyncCallback<Window>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------------------------------------- | ---- | ---------------------------- |
| -------- | -------------------------------------- | ---- | ----------------------------
--------
|
| id | string | 是 | 窗口id。 |
| id | string | 是 | 窗口id。
|
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
返回当前查找
的窗口对象。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
函数。返回当前查找到
的窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
window
.
find
(
"
alertWindow
"
,
(
err
,
data
)
=>
{
window
.
find
(
"
alertWindow
"
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to find the Window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to find the Window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
window found. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
window found. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
## window.find<sup>7+</sup>
## window.find<sup>7+</sup>
...
@@ -361,22 +364,22 @@ find(id: string): Promise<Window>
...
@@ -361,22 +364,22 @@ find(id: string): Promise<Window>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------- | -------------------------------------
----------
|
| -------------------------------- | ------------------------------------- |
| Promise
<
[Window](#window)
>
|
以Promise形式返回结果,
返回当前查找的窗口对象。 |
| Promise
<
[Window](#window)
>
|
Promise对象。
返回当前查找的窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
let
promise
=
window
.
find
(
"
alertWindow
"
);
let
promise
=
window
.
find
(
"
alertWindow
"
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
window found. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
window found. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to find the Window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to find the Window. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
## window.getTopWindow
## window.getTopWindow
...
@@ -384,29 +387,29 @@ getTopWindow(callback: AsyncCallback<Window>): void
...
@@ -384,29 +387,29 @@ getTopWindow(callback: AsyncCallback<Window>): void
获取当前应用内最后显示的窗口,使用callback异步回调。
获取当前应用内最后显示的窗口,使用callback异步回调。
从API version 8开始,此接口废弃,推荐使用
[
window.getTopWindow<sup>8+</sup>
](
#windowgettopwindow8
)
接口
。
此接口仅可在FA模型下使用
。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------------------------------------- | ---- | -------------------------------------- |
| -------- | -------------------------------------- | ---- | --------------------------------------
------
|
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调返回当前应用内最后显示的窗口对象。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
函数。
返回当前应用内最后显示的窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
window
.
getTopWindow
((
err
,
data
)
=>
{
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
## window.getTopWindow
## window.getTopWindow
...
@@ -414,28 +417,28 @@ getTopWindow(): Promise<Window>
...
@@ -414,28 +417,28 @@ getTopWindow(): Promise<Window>
获取当前应用内最后显示的窗口,使用Promise异步回调。
获取当前应用内最后显示的窗口,使用Promise异步回调。
从API version 8开始,此接口废弃,推荐使用
[
window.getTopWindow<sup>8+</sup>
](
#windowgettopwindow8
)
接口
。
此接口仅可在FA模型下使用
。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------- | -----------------------------------------------
----------
|
| -------------------------------- | ----------------------------------------------- |
| Promise
<
[Window](#window)
>
|
以Promise形式返回结果,
返回当前应用内最后显示的窗口对象。 |
| Promise
<
[Window](#window)
>
|
Promise对象。
返回当前应用内最后显示的窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
let
promise
=
window
.
getTopWindow
();
let
promise
=
window
.
getTopWindow
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
## window.getTopWindow<sup>8+</sup>
## window.getTopWindow<sup>8+</sup>
...
@@ -443,6 +446,8 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
...
@@ -443,6 +446,8 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
获取当前应用内最后显示的窗口,使用callback异步回调。
获取当前应用内最后显示的窗口,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -450,21 +455,21 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
...
@@ -450,21 +455,21 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | 是 | 当前应用上下文信息。
<br>
API version 8的Context定义见
[
Context
](
js-apis-Context.md
)
。
<br>
API version 9的Context定义见
[
Context
](
js-apis-ability-context.md
)
。 |
| 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
<
[Window](#window)
>
| 是 | 回调
返回当前应用内最后显示的窗口对象。
|
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调
函数。返回当前应用内最后显示的窗口对象。
|
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
window
.
getTopWindow
(
this
.
context
,
(
err
,
data
)
=>
{
window
.
getTopWindow
(
this
.
context
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
## window.getTopWindow<sup>8+</sup>
## window.getTopWindow<sup>8+</sup>
...
@@ -472,6 +477,8 @@ getTopWindow(ctx: Context): Promise<Window>
...
@@ -472,6 +477,8 @@ getTopWindow(ctx: Context): Promise<Window>
获取当前应用内最后显示的窗口,使用Promise异步回调。
获取当前应用内最后显示的窗口,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -482,28 +489,28 @@ getTopWindow(ctx: Context): Promise<Window>
...
@@ -482,28 +489,28 @@ getTopWindow(ctx: Context): Promise<Window>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------- | -----------------------------------------------
----------
|
| -------------------------------- | ----------------------------------------------- |
| Promise
<
[Window](#window)
>
|
以Promise形式返回结果,
返回当前应用内最后显示的窗口对象。 |
| Promise
<
[Window](#window)
>
|
Promise对象。
返回当前应用内最后显示的窗口对象。 |
**示例:**
**示例:**
```
js
```
js
var
windowClass
=
null
;
var
windowClass
=
null
;
let
promise
=
window
.
getTopWindow
(
this
.
context
);
let
promise
=
window
.
getTopWindow
(
this
.
context
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in obtaining the top window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the top window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
## on('systemBarTintChange')<sup>8+</sup>
## on('systemBarTintChange')<sup>8+</sup>
on(type: 'systemBarTintChange', callback: Callback
<
SystemBarTintState
>
): void
on(type: 'systemBarTintChange', callback: Callback
<
SystemBarTintState
>
): void
注册状态栏、导航栏的监听函数
。
开启状态栏、导航栏属性变化的监听
。
此接口为系统接口,三方应用不支持调用。
此接口为系统接口,三方应用不支持调用。
...
@@ -514,22 +521,21 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v
...
@@ -514,22 +521,21 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback
<
[SystemBarTintState](#systembartintstate)
>
| 是 | 回调
返回监听到的信息。
|
| callback | Callback
<
[SystemBarTintState](#systembartintstate)
>
| 是 | 回调
函数。返回当前的状态栏、导航栏信息集合。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
systemBarTintChange
'
;
window
.
on
(
'
systemBarTintChange
'
,
(
data
)
=>
{
windowClass
.
on
(
type
,
(
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
));
});
});
```
```
## off('systemBarTintChange')<sup>8+</sup>
## off('systemBarTintChange')<sup>8+</sup>
off(type: 'systemBarTintChange', callback?: Callback
<
SystemBarTintState
>
): void
off(type: 'systemBarTintChange', callback?: Callback
<
SystemBarTintState
>
): void
关闭监听。
关闭
状态栏、导航栏属性变化的
监听。
此接口为系统接口,三方应用不支持调用。
此接口为系统接口,三方应用不支持调用。
...
@@ -540,17 +546,18 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >)
...
@@ -540,17 +546,18 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >)
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback
<
[SystemBarTintState](#systembartintstate)
>
| 否 | 回调
返回监听到的信息。
|
| callback | Callback
<
[SystemBarTintState](#systembartintstate)
>
| 否 | 回调
函数。返回当前的状态栏、导航栏信息集合。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
systemBarTintChange
'
;
window
.
off
(
'
systemBarTintChange
'
);
windowClass
.
off
(
type
);
```
```
## Window
## Window
当前窗口实例,窗口管理器管理的基本单元。
下列API示例中都需先使用
[
getTopWindow()
](
#windowgettopwindow
)
、
[
create()
](
#windowcreate7
)
、
[
find()
](
#windowfind7
)
中的任一方法获取到Window实例,再通过此实例调用对应方法。
下列API示例中都需先使用
[
getTopWindow()
](
#windowgettopwindow
)
、
[
create()
](
#windowcreate7
)
、
[
find()
](
#windowfind7
)
中的任一方法获取到Window实例,再通过此实例调用对应方法。
### hide<sup>7+</sup>
### hide<sup>7+</sup>
...
@@ -571,15 +578,15 @@ hide (callback: AsyncCallback<void>): void
...
@@ -571,15 +578,15 @@ hide (callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
hide
((
err
,
data
)
=>
{
windowClass
.
hide
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
window hidden. data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
window hidden. data:
'
+
JSON
.
stringify
(
data
));
})
})
```
```
### hide<sup>7+</sup>
### hide<sup>7+</sup>
...
@@ -593,20 +600,20 @@ hide(): Promise<void>
...
@@ -593,20 +600,20 @@ hide(): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
hide
();
let
promise
=
windowClass
.
hide
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
window hidden. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
window hidden. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
### show<sup>7+</sup>
### show<sup>7+</sup>
...
@@ -624,15 +631,15 @@ show(callback: AsyncCallback<void>): void
...
@@ -624,15 +631,15 @@ show(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
show
((
err
,
data
)
=>
{
windowClass
.
show
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in showing the window. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in showing the window. Data:
'
+
JSON
.
stringify
(
data
));
})
})
```
```
### show<sup>7+</sup>
### show<sup>7+</sup>
...
@@ -644,20 +651,20 @@ show(): Promise<void>
...
@@ -644,20 +651,20 @@ show(): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
show
();
let
promise
=
windowClass
.
show
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in showing the window. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in showing the window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
### destroy<sup>7+</sup>
### destroy<sup>7+</sup>
...
@@ -675,15 +682,15 @@ destroy(callback: AsyncCallback<void>): void
...
@@ -675,15 +682,15 @@ destroy(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
destroy
((
err
,
data
)
=>
{
windowClass
.
destroy
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in destroying the window. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in destroying the window. Data:
'
+
JSON
.
stringify
(
data
));
})
})
```
```
### destroy<sup>7+</sup>
### destroy<sup>7+</sup>
...
@@ -695,20 +702,20 @@ destroy(): Promise<void>
...
@@ -695,20 +702,20 @@ destroy(): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
destroy
();
let
promise
=
windowClass
.
destroy
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in destroying 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 destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
### moveTo<sup>7+</sup>
### moveTo<sup>7+</sup>
...
@@ -728,16 +735,16 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void
...
@@ -728,16 +735,16 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
moveTo
(
300
,
300
,
(
err
,
data
)
=>
{
windowClass
.
moveTo
(
300
,
300
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Window moved. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window moved. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### moveTo<sup>7+</sup>
### moveTo<sup>7+</sup>
...
@@ -756,20 +763,20 @@ moveTo(x: number, y: number): Promise<void>
...
@@ -756,20 +763,20 @@ moveTo(x: number, y: number): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
moveTo
(
300
,
300
);
let
promise
=
windowClass
.
moveTo
(
300
,
300
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Window moved. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window moved. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
```
```
### resetSize<sup>7+</sup>
### resetSize<sup>7+</sup>
...
@@ -789,15 +796,15 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v
...
@@ -789,15 +796,15 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v
**示例:**
**示例:**
```
js
```
js
windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Window size changed. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window size changed. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### resetSize<sup>7+</sup>
### resetSize<sup>7+</sup>
...
@@ -816,20 +823,20 @@ resetSize(width: number, height: number): Promise<void>
...
@@ -816,20 +823,20 @@ resetSize(width: number, height: number): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
resetSize
(
500
,
1000
);
let
promise
=
windowClass
.
resetSize
(
500
,
1000
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Window size changed. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Window size changed. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setWindowType<sup>7+</sup>
### setWindowType<sup>7+</sup>
...
@@ -850,16 +857,16 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void
...
@@ -850,16 +857,16 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
var
type
=
window
.
TYPE_APP
;
var
type
=
window
.
WindowType
.
TYPE_APP
;
windowClass
.
setWindowType
(
type
,
(
err
,
data
)
=>
{
windowClass
.
setWindowType
(
type
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window type. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window type. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the window type. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the window type. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setWindowType<sup>7+</sup>
### setWindowType<sup>7+</sup>
...
@@ -879,21 +886,21 @@ setWindowType(type: WindowType): Promise<void>
...
@@ -879,21 +886,21 @@ setWindowType(type: WindowType): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
type
=
window
.
TYPE_APP
;
var
type
=
window
.
WindowType
.
TYPE_APP
;
let
promise
=
windowClass
.
setWindowType
(
type
);
let
promise
=
windowClass
.
setWindowType
(
type
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the window type. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the window type. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the window type. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window type. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### getProperties
### getProperties
...
@@ -905,21 +912,21 @@ getProperties(callback: AsyncCallback<WindowProperties>): void
...
@@ -905,21 +912,21 @@ getProperties(callback: AsyncCallback<WindowProperties>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------------------------- | ---- | ------------------ |
| -------- | ---------------------------------------------------------- | ---- | ------------------
----------
|
| callback | AsyncCallback
<
[WindowProperties](#windowproperties)
>
| 是 | 回调
返回
窗口属性。 |
| callback | AsyncCallback
<
[WindowProperties](#windowproperties)
>
| 是 | 回调
函数。返回当前
窗口属性。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
getProperties
((
err
,
data
)
=>
{
windowClass
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the window properties. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the window properties. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in obtaining the window properties. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in obtaining the window properties. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### getProperties
### getProperties
...
@@ -931,20 +938,20 @@ getProperties(): Promise<WindowProperties>
...
@@ -931,20 +938,20 @@ getProperties(): Promise<WindowProperties>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ---------------------------------------------------- | -------------------------------
------
|
| ---------------------------------------------------- | ------------------------------- |
| Promise
<
[WindowProperties](#windowproperties)
>
|
以Promise形式返回结果,返回
窗口属性。 |
| Promise
<
[WindowProperties](#windowproperties)
>
|
Promise对象。返回当前
窗口属性。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
getProperties
();
let
promise
=
windowClass
.
getProperties
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in obtaining the window properties. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in obtaining the window properties. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the window properties. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the window properties. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### getAvoidArea<sup>7+</sup>
### getAvoidArea<sup>7+</sup>
...
@@ -959,20 +966,20 @@ getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): voi
...
@@ -959,20 +966,20 @@ getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): voi
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| type |
[
AvoidAreaType
](
#avoidareatype
)
| 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。 |
| type |
[
AvoidAreaType
](
#avoidareatype
)
| 是 | 表示规避区类型。type为TYPE_SYSTEM,表示系统默认区域。type为TYPE_CUTOUT,表示刘海屏区域。 |
| callback | AsyncCallback
<
[AvoidArea](#avoidarea)
>
| 是 | 回调
返回窗口内容规避区域。
|
| callback | AsyncCallback
<
[AvoidArea](#avoidarea)
>
| 是 | 回调
函数。返回窗口内容规避区域。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
window
.
AvoidAreaType
.
TYPE_SYSTEM
;
var
type
=
window
.
AvoidAreaType
.
TYPE_SYSTEM
;
windowClass
.
getAvoidArea
(
type
,
(
err
,
data
)
=>
{
windowClass
.
getAvoidArea
(
type
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the area. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the area. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in obtaining the area. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in obtaining the area. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### getAvoidArea<sup>7+</sup>
### getAvoidArea<sup>7+</sup>
...
@@ -990,20 +997,20 @@ getAvoidArea(type: AvoidAreaType): Promise<AvoidArea>
...
@@ -990,20 +997,20 @@ getAvoidArea(type: AvoidAreaType): Promise<AvoidArea>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| -------------------------------------- | -----------------------------------
----------
|
| -------------------------------------- | ----------------------------------- |
| Promise
<
[AvoidArea](#avoidarea)
>
|
以Promise形式返回结果,
返回窗口内容规避区域。 |
| Promise
<
[AvoidArea](#avoidarea)
>
|
Promise对象。
返回窗口内容规避区域。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
getAvoidArea
();
let
promise
=
windowClass
.
getAvoidArea
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in obtaining the area. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in obtaining the area. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the area. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to obtain the area. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setFullScreen
### setFullScreen
...
@@ -1022,16 +1029,16 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void
...
@@ -1022,16 +1029,16 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
var
isFullScreen
=
true
;
var
isFullScreen
=
true
;
windowClass
.
setFullScreen
(
isFullScreen
,
(
err
,
data
)
=>
{
windowClass
.
setFullScreen
(
isFullScreen
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in enabling the full-screen mode. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in enabling the full-screen mode. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setFullScreen
### setFullScreen
...
@@ -1049,21 +1056,21 @@ setFullScreen(isFullScreen: boolean): Promise<void>
...
@@ -1049,21 +1056,21 @@ setFullScreen(isFullScreen: boolean): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isFullScreen
=
true
;
var
isFullScreen
=
true
;
let
promise
=
windowClass
.
setFullScreen
(
isFullScreen
);
let
promise
=
windowClass
.
setFullScreen
(
isFullScreen
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in enabling the full-screen mode. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in enabling the full-screen mode. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setLayoutFullScreen<sup>7+</sup>
### setLayoutFullScreen<sup>7+</sup>
...
@@ -1082,16 +1089,16 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void
...
@@ -1082,16 +1089,16 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void
**示例:**
**示例:**
```
js
```
js
var
isLayoutFullScreen
=
true
;
var
isLayoutFullScreen
=
true
;
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
,
data
)
=>
{
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setLayoutFullScreen<sup>7+</sup>
### setLayoutFullScreen<sup>7+</sup>
...
@@ -1109,21 +1116,21 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
...
@@ -1109,21 +1116,21 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isLayoutFullScreen
=
true
;
var
isLayoutFullScreen
=
true
;
let
promise
=
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
);
let
promise
=
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setSystemBarEnable<sup>7+</sup>
### setSystemBarEnable<sup>7+</sup>
...
@@ -1137,21 +1144,21 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac
...
@@ -1137,21 +1144,21 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为["status",
"navigation"],
不设置,则默认不显示。 |
| names | Array | 是 | 设置状态栏和导航栏是否显示。
<br>
例如,需全部显示,该参数设置为["status",
"navigation"];
不设置,则默认不显示。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
js
```
js
var
names
=
[
"
status
"
,
"
navigation
"
];
var
names
=
[
"
status
"
,
"
navigation
"
];
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 visible. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the system bar to be visible. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the system bar to be visible. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setSystemBarEnable<sup>7+</sup>
### setSystemBarEnable<sup>7+</sup>
...
@@ -1165,25 +1172,25 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
...
@@ -1165,25 +1172,25 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----- | ---- | ------------------------------------------------------------ |
| ------ | ----- | ---- | ------------------------------------------------------------ |
| names | Array | 是 | 设置状态栏和导航栏是否显示。
例如,需全部显示,该参数设置为["status",
"navigation"],
不设置,则默认不显示。 |
| names | Array | 是 | 设置状态栏和导航栏是否显示。
<br>
例如,需全部显示,该参数设置为["status",
"navigation"];
不设置,则默认不显示。 |
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
names
=
[
"
status
"
,
"
navigation
"
];
var
names
=
[
"
status
"
,
"
navigation
"
];
let
promise
=
windowClass
.
setSystemBarEnable
(
names
);
let
promise
=
windowClass
.
setSystemBarEnable
(
names
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the system bar to be visible. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the system bar to be visible. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setSystemBarProperties
### setSystemBarProperties
...
@@ -1195,32 +1202,32 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async
...
@@ -1195,32 +1202,32 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| ------------------- | ------------------------------------------- | ---- | -------------------- |
| ------------------- | ------------------------------------------- | ---- | --------------------
--
|
| SystemBarProperties |
[
SystemBarProperties
](
#systembarproperties
)
| 是 | 导航栏状态栏的属性。 |
| SystemBarProperties |
[
SystemBarProperties
](
#systembarproperties
)
| 是 | 导航栏
、
状态栏的属性。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。
|
**示例:**
**示例:**
```
js
```
js
var
SystemBarProperties
=
{
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
navigationBarColor
:
'
#00ff00
'
,
//以下两个属性从API Version7开始支持
//以下两个属性从API Version7开始支持
isStatusBarLightIcon
:
true
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
isNavigationBarLightIcon
:
false
,
//以下两个属性从API Version8开始支持
//以下两个属性从API Version8开始支持
statusBarContentColor
:
'
#ffffff
'
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
navigationBarContentColor
:
'
#00ffff
'
};
};
windowClass
.
setSystemBarProperties
(
SystemBarProperties
,
(
err
,
data
)
=>
{
windowClass
.
setSystemBarProperties
(
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
));
});
});
```
```
### setSystemBarProperties
### setSystemBarProperties
...
@@ -1232,42 +1239,42 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi
...
@@ -1232,42 +1239,42 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| ------------------- | ------------------------------------------- | ---- | -------------------- |
| ------------------- | ------------------------------------------- | ---- | --------------------
--
|
| SystemBarProperties |
[
SystemBarProperties
](
#systembarproperties
)
| 是 | 导航栏状态栏的属性。 |
| SystemBarProperties |
[
SystemBarProperties
](
#systembarproperties
)
| 是 | 导航栏
、
状态栏的属性。 |
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
SystemBarProperties
=
{
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
navigationBarColor
:
'
#00ff00
'
,
//以下两个属性从API Version7开始支持
//以下两个属性从API Version7开始支持
isStatusBarLightIcon
:
true
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
isNavigationBarLightIcon
:
false
,
//以下两个属性从API Version8开始支持
//以下两个属性从API Version8开始支持
statusBarContentColor
:
'
#ffffff
'
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
navigationBarContentColor
:
'
#00ffff
'
};
};
let
promise
=
windowClass
.
setSystemBarProperties
(
SystemBarProperties
);
let
promise
=
windowClass
.
setSystemBarProperties
(
SystemBarProperties
);
promise
.
then
((
data
)
=>
{
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
));
});
});
```
```
### loadContent<sup>7+</sup>
### loadContent<sup>7+</sup>
loadContent(path: string, callback: AsyncCallback
<
void
>
): void
loadContent(path: string, callback: AsyncCallback
<
void
>
): void
当前窗口加载具体页面内容,使用callback异步回调。
为
当前窗口加载具体页面内容,使用callback异步回调。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -1280,21 +1287,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
...
@@ -1280,21 +1287,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
loadContent
(
"
pages/page2/page2
"
,
(
err
,
data
)
=>
{
windowClass
.
loadContent
(
"
pages/page2/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
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### loadContent<sup>7+</sup>
### loadContent<sup>7+</sup>
loadContent(path: string): Promise
<
void
>
loadContent(path: string): Promise
<
void
>
当前窗口加载具体页面内容,使用Promise异步回调。
为
当前窗口加载具体页面内容,使用Promise异步回调。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -1306,21 +1313,101 @@ loadContent(path: string): Promise<void>
...
@@ -1306,21 +1313,101 @@ loadContent(path: string): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
loadContent
(
"
pages/page2/page2
"
);
let
promise
=
windowClass
.
loadContent
(
"
pages/page2/page2
"
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
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
));
});
});
```
```
### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback
<
void
>
): void
为当前窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 设置加载页面的路径。 |
| storage |
[
LocalStorage
](
../ui/ui-ts-local-storage.md
)
| 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
```
ts
class
myAbility
extends
Ability
{
storage
:
LocalStorage
onWindowStageCreate
(
windowStage
)
{
this
.
storage
=
new
LocalStorage
();
this
.
storage
.
setOrCreate
(
"
storageSimpleProp
"
,
121
);
console
.
log
(
'
onWindowStageCreate
'
);
windowStage
.
loadContent
(
"
pages/page2
"
,
this
.
storage
,(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
});
}
}
```
### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage): Promise
<
void
>
为当前窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 设置加载页面的路径。 |
| storage |
[
LocalStorage
](
../ui/ui-ts-local-storage.md
)
| 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
ts
class
myAbility
extends
Ability
{
storage
:
LocalStorage
onWindowStageCreate
(
windowStage
)
{
this
.
storage
=
new
LocalStorage
();
this
.
storage
.
setOrCreate
(
"
storageSimpleProp
"
,
121
);
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
loadContent
(
"
pages/page2
"
,
this
.
storage
);
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### isShowing<sup>7+</sup>
### isShowing<sup>7+</sup>
isShowing(callback: AsyncCallback
<
boolean
>
): void
isShowing(callback: AsyncCallback
<
boolean
>
): void
...
@@ -1331,21 +1418,21 @@ isShowing(callback: AsyncCallback<boolean>): void
...
@@ -1331,21 +1418,21 @@ isShowing(callback: AsyncCallback<boolean>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------- | ---- | -------------------------------- |
| -------- | ---------------------------- | ---- | --------------------------------
----------------------------
|
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数
返回是否显示子窗口结果
。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数
。返回true表示当前窗口已显示,返回false则表示当前窗口未显示
。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
isShowing
((
err
,
data
)
=>
{
windowClass
.
isShowing
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to check whether the window is showing. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to check whether the window is showing. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in checking whether the window is showing. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in checking whether the window is showing. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### isShowing<sup>7+</sup>
### isShowing<sup>7+</sup>
...
@@ -1357,50 +1444,49 @@ isShowing(): Promise<boolean>
...
@@ -1357,50 +1444,49 @@ isShowing(): Promise<boolean>
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明
|
| ---------------------- | ----------------------------------------------------- |
| ---------------------- | -----------------------------------------------------
-------
|
| Promise
<
boolean
>
|
以Promise形式返回结果,返回当前窗口是否已显示的结果
。 |
| Promise
<
boolean
>
|
Promise对象。返回true表示当前窗口已显示,返回false则表示当前窗口未显示
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
isShowing
();
let
promise
=
windowClass
.
isShowing
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in checking whether the window is showing. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in checking whether the window is showing. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to check whether the window is showing. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to check whether the window is showing. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### on('windowSizeChange')<sup>7+</sup>
### on('windowSizeChange')<sup>7+</sup>
on(type: 'windowSizeChange', callback: Callback
<
Size
>
): void
on(type: 'windowSizeChange', callback: Callback
<
Size
>
): void
开启监听。
开启
窗口尺寸变化的
监听。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型
| 必填 | 说明 |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| -------- | -----------------------------
-
| ---- | -------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
| type | string
| 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
| callback | Callback
<
[Size](#size
)
>
| 是 | 回调返回监听到的信息。
|
| callback | Callback
<
[Size](#size
7)
>
| 是 | 回调函数。返回当前的窗口尺寸。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
windowSizeChange
'
;
windowClass
.
on
(
'
windowSizeChange
'
,
(
data
)
=>
{
windowClass
.
on
(
type
,
(
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
));
});
});
```
```
### off('windowSizeChange')<sup>7+</sup>
### off('windowSizeChange')<sup>7+</sup>
off(type: 'windowSizeChange', callback?: Callback
<
Size
>
): void
off(type: 'windowSizeChange', callback?: Callback
<
Size
>
): void
关闭监听。
关闭
窗口尺寸变化的
监听。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -1409,20 +1495,19 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void
...
@@ -1409,20 +1495,19 @@ off(type: 'windowSizeChange', callback?: Callback<Size >): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| -------- | ----------------------------- | ---- | -------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
| type | string | 是 | 监听事件,固定为'windowSizeChange',即窗口尺寸变化事件。 |
| callback | Callback
<
[Size](#size)
>
| 否 | 回调
返回监听到的信息。
|
| callback | Callback
<
[Size](#size)
>
| 否 | 回调
函数。返回当前的窗口尺寸。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
windowSizeChange
'
;
windowClass
.
off
(
'
windowSizeChange
'
);
windowClass
.
off
(
type
);
```
```
### on('systemAvoidAreaChange')<sup>7+</sup>
### on('systemAvoidAreaChange')<sup>7+</sup>
on(type: 'systemAvoidAreaChange', callback: Callback
<
AvoidArea
>
): void
on(type: 'systemAvoidAreaChange', callback: Callback
<
AvoidArea
>
): void
开启监听。
开启
系统窗口规避区变化的
监听。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -1431,22 +1516,21 @@ on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void
...
@@ -1431,22 +1516,21 @@ on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
| callback | Callback
<
[AvoidArea](#avoidarea)
>
| 是 | 回调
返回监听到的信息。
|
| callback | Callback
<
[AvoidArea](#avoidarea)
>
| 是 | 回调
函数。返回当前的窗口规避区。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
systemAvoidAreaChange
'
;
windowClass
.
on
(
'
systemAvoidAreaChange
'
,
(
data
)
=>
{
windowClass
.
on
(
type
,
(
data
)
=>
{
console
.
info
(
'
Succeeded in enabling the listener for system avoid area changes. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in enabling the listener for system avoid area changes. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### off('systemAvoidAreaChange')<sup>7+</sup>
### off('systemAvoidAreaChange')<sup>7+</sup>
off(type: 'systemAvoidAreaChange', callback?: Callback
<
AvoidArea
>
): void
off(type: 'systemAvoidAreaChange', callback?: Callback
<
AvoidArea
>
): void
关闭监听。
关闭
系统窗口规避区变化的
监听。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -1455,14 +1539,13 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void
...
@@ -1455,14 +1539,13 @@ off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
| type | string | 是 | 监听事件,固定为'systemAvoidAreaChange',即系统窗口规避区变化事件。 |
| callback | Callback
<
[AvoidArea](#avoidarea)
>
| 否 | 回调
返回监听到的信息。
|
| callback | Callback
<
[AvoidArea](#avoidarea)
>
| 否 | 回调
函数。返回当前的窗口规避区。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
systemAvoidAreaChange
'
;
windowClass
.
off
(
'
systemAvoidAreaChange
'
);
windowClass
.
off
(
type
);
```
```
### on('keyboardHeightChange')<sup>7+</sup>
### on('keyboardHeightChange')<sup>7+</sup>
...
@@ -1474,19 +1557,18 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void
...
@@ -1474,19 +1557,18 @@ on(type: 'keyboardHeightChange', callback: Callback<number>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型
| 必填 | 说明 |
| -------- | ------------------ | ---- | ------------------------------------------------------------ |
| -------- | ------------------
-
| ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
| type | string
| 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
| callback | Callback
number
>
| 是 | 回调返回监听到的信息。
|
| callback | Callback
<number
>
| 是 | 回调函数。返回当前的键盘高度。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
keyboardHeightChange
'
;
windowClass
.
on
(
'
keyboardHeightChange
'
,
(
data
)
=>
{
windowClass
.
on
(
type
,
(
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
));
});
});
```
```
### off('keyboardHeightChange')<sup>7+</sup>
### off('keyboardHeightChange')<sup>7+</sup>
...
@@ -1501,14 +1583,13 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void
...
@@ -1501,14 +1583,13 @@ off(type: 'keyboardHeightChange', callback?: Callback<number>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
| type | string | 是 | 监听事件,固定为'keyboardHeightChange',即键盘高度变化事件。 |
| callback | Callback
<
number
>
| 否 | 回调
返回监听到的信息。
|
| callback | Callback
<
number
>
| 否 | 回调
函数。返回当前的键盘高度。
|
**示例:**
**示例:**
```
js
```
js
var
type
=
'
keyboardHeightChange
'
;
windowClass
.
off
(
'
keyboardHeightChange
'
);
windowClass
.
off
(
type
);
```
```
### isSupportWideGamut<sup>8+</sup>
### isSupportWideGamut<sup>8+</sup>
...
@@ -1520,21 +1601,21 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void
...
@@ -1520,21 +1601,21 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------- | ---- | -------------------------------- |
| -------- | ---------------------------- | ---- | --------------------------------
----------------------------
|
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数
返回是否
支持广色域模式。 |
| callback | AsyncCallback
<
boolean
>
| 是 | 回调函数
。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不
支持广色域模式。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
isSupportWideGamut
((
err
,
data
)
=>
{
windowClass
.
isSupportWideGamut
((
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>
### isSupportWideGamut<sup>8+</sup>
...
@@ -1548,18 +1629,18 @@ isSupportWideGamut(): Promise<boolean>
...
@@ -1548,18 +1629,18 @@ isSupportWideGamut(): Promise<boolean>
| 类型 | 说明 |
| 类型 | 说明 |
| ---------------------- | ------------------------------------------------------------ |
| ---------------------- | ------------------------------------------------------------ |
| Promise
<
boolean
>
|
以Promise形式返回结果,返回当前窗口是否支持广色域模式的结果
。 |
| Promise
<
boolean
>
|
Promise对象。返回true表示当前窗口支持广色域模式,返回false则表示当前窗口不支持广色域模式
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
isSupportWideGamut
();
let
promise
=
windowClass
.
isSupportWideGamut
();
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
)
=>
{
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
));
});
});
```
```
### setColorSpace<sup>8+</sup>
### setColorSpace<sup>8+</sup>
...
@@ -1578,15 +1659,15 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
...
@@ -1578,15 +1659,15 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
windowClass
.
setColorSpace
(
window
.
ColorSpace
.
WIDE_GAMUT
,
(
err
,
data
)
=>
{
windowClass
.
setColorSpace
(
window
.
ColorSpace
.
WIDE_GAMUT
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting window colorspace. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting window colorspace. Data:
'
+
JSON
.
stringify
(
data
));
})
})
```
```
### setColorSpace<sup>8+</sup>
### setColorSpace<sup>8+</sup>
...
@@ -1598,26 +1679,26 @@ setColorSpace(colorSpace:ColorSpace): Promise<void>
...
@@ -1598,26 +1679,26 @@ setColorSpace(colorSpace:ColorSpace): Promise<void>
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| ---------- | ------------------------- | ---- | ------------ |
| ---------- | ------------------------- | ---- | ------------
--
|
| colorSpace |
[
ColorSpace
](
#colorspace
)
| 是 | 设置色域模式 |
| colorSpace |
[
ColorSpace
](
#colorspace
)
| 是 | 设置色域模式
。
|
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
isSupportWideGamut
(
window
.
ColorSpace
.
WIDE_GAMUT
);
let
promise
=
windowClass
.
isSupportWideGamut
(
window
.
ColorSpace
.
WIDE_GAMUT
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting window colorspace. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting window colorspace. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### getColorSpace<sup>8+</sup>
### getColorSpace<sup>8+</sup>
...
@@ -1629,21 +1710,21 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void
...
@@ -1629,21 +1710,21 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------------- | ---- | -------------------------- |
| -------- | ---------------------------------------------- | ---- | --------------------------
--------------------------------
|
| callback | AsyncCallback
<
[ColorSpace](#colorspace)
>
| 是 | 回调函数
返回
当前色域模式。 |
| callback | AsyncCallback
<
[ColorSpace](#colorspace)
>
| 是 | 回调函数
。当获取成功,err为undefined,data为
当前色域模式。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
getColorSpace
((
err
,
data
)
=>
{
windowClass
.
getColorSpace
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to get window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to get window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in getting window colorspace. Cause:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in getting window colorspace. Cause:
'
+
JSON
.
stringify
(
data
));
})
})
```
```
### getColorSpace<sup>8+</sup>
### getColorSpace<sup>8+</sup>
...
@@ -1655,20 +1736,20 @@ getColorSpace(): Promise<ColorSpace>
...
@@ -1655,20 +1736,20 @@ getColorSpace(): Promise<ColorSpace>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ---------------------------------------- | -------------------------------
----------
|
| ---------------------------------------- | ------------------------------- |
| Promise
<
[ColorSpace](#colorspace)
>
|
以Promise形式返回结果,
返回当前色域模式。 |
| Promise
<
[ColorSpace](#colorspace)
>
|
Promise对象。
返回当前色域模式。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
getColorSpace
();
let
promise
=
windowClass
.
getColorSpace
();
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in getting window color space. Cause:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in getting window color space. Cause:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to get window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to get window colorspace. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setBackgroundColor
### setBackgroundColor
...
@@ -1682,21 +1763,21 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void
...
@@ -1682,21 +1763,21 @@ setBackgroundColor(color: string, callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如
"#00FF00"或"#FF00FF00"
。 |
| color | string | 是 | 需要设置的背景色,为十六进制颜色,不区分大小写,例如
`#00FF00`
或
`#FF00FF00`
。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
js
```
js
var
color
=
'
#00ff33
'
;
var
color
=
'
#00ff33
'
;
windowClass
.
setBackgroundColor
(
color
,
(
err
,
data
)
=>
{
windowClass
.
setBackgroundColor
(
color
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the background color. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the background color. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the background color. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the background color. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setBackgroundColor
### setBackgroundColor
...
@@ -1714,21 +1795,21 @@ setBackgroundColor(color: string): Promise<void>
...
@@ -1714,21 +1795,21 @@ setBackgroundColor(color: string): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
color
=
'
#00ff33
'
;
var
color
=
'
#00ff33
'
;
let
promise
=
windowClass
.
setBackgroundColor
(
color
);
let
promise
=
windowClass
.
setBackgroundColor
(
color
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the background color. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the background color. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the background color. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the background color. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setBrightness
### setBrightness
...
@@ -1747,16 +1828,16 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void
...
@@ -1747,16 +1828,16 @@ setBrightness(brightness: number, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
var
brightness
=
1
;
var
brightness
=
1
;
windowClass
.
setBrightness
(
brightness
,
(
err
,
data
)
=>
{
windowClass
.
setBrightness
(
brightness
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the brightness. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the brightness. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the brightness. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the brightness. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setBrightness
### setBrightness
...
@@ -1774,27 +1855,27 @@ setBrightness(brightness: number): Promise<void>
...
@@ -1774,27 +1855,27 @@ setBrightness(brightness: number): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
brightness
=
1
;
var
brightness
=
1
;
let
promise
=
windowClass
.
setBrightness
(
brightness
);
let
promise
=
windowClass
.
setBrightness
(
brightness
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the brightness. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the brightness. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the brightness. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the brightness. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setDimBehind<sup>(deprecated)</sup>
### setDimBehind<sup>(deprecated)</sup>
setDimBehind(dimBehindValue: number, callback: AsyncCallback
<
void
>
): void
setDimBehind(dimBehindValue: number, callback: AsyncCallback
<
void
>
): void
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback
方式作为异步方法
。
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback
异步回调
。
> **说明:** 从API version 9开始废弃。
> **说明:** 从API version 9开始废弃。
>
>
...
@@ -1804,28 +1885,28 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
...
@@ -1804,28 +1885,28 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
| -------------- | ------------------------- | ---- | -------------------------------------------------- |
| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
setDimBehind
(
0.5
,
(
err
,
data
)
=>
{
windowClass
.
setDimBehind
(
0.5
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the dimness. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the dimness. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the dimness. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the dimness. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setDimBehind<sup>(deprecated)</sup>
### setDimBehind<sup>(deprecated)</sup>
setDimBehind(dimBehindValue: number): Promise
<
void
>
setDimBehind(dimBehindValue: number): Promise
<
void
>
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise
方式作为异步方法
。
窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise
异步回调
。
> **说明:** 从API version 9开始废弃。
> **说明:** 从API version 9开始废弃。
>
>
...
@@ -1835,26 +1916,26 @@ setDimBehind(dimBehindValue: number): Promise<void>
...
@@ -1835,26 +1916,26 @@ setDimBehind(dimBehindValue: number): Promise<void>
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------------------------------------- |
| -------------- | ------ | ---- | -------------------------------------------------- |
| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
| dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 |
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明
|
| ------------------- | ----------------------
------------------------- |
| ------------------- |
------------------------- |
| Promise
<
void
>
| 以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
| 无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
setDimBehind
(
0.5
);
let
promise
=
windowClass
.
setDimBehind
(
0.5
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the dimness. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the dimness. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the dimness. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the dimness. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setFocusable<sup>7+</sup>
### setFocusable<sup>7+</sup>
...
@@ -1873,16 +1954,16 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
...
@@ -1873,16 +1954,16 @@ setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
var
isFocusable
=
true
;
var
isFocusable
=
true
;
windowClass
.
setFocusable
(
isFocusable
,
(
err
,
data
)
=>
{
windowClass
.
setFocusable
(
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
));
});
});
```
```
### setFocusable<sup>7+</sup>
### setFocusable<sup>7+</sup>
...
@@ -1900,21 +1981,21 @@ setFocusable(isFocusable: boolean): Promise<void>
...
@@ -1900,21 +1981,21 @@ setFocusable(isFocusable: boolean): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isFocusable
=
true
;
var
isFocusable
=
true
;
let
promise
=
windowClass
.
setFocusable
(
isFocusable
);
let
promise
=
windowClass
.
setFocusable
(
isFocusable
);
promise
.
then
((
data
)
=>
{
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
));
});
});
```
```
### setKeepScreenOn
### setKeepScreenOn
...
@@ -1933,53 +2014,54 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v
...
@@ -1933,53 +2014,54 @@ setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): v
**示例:**
**示例:**
```
js
```
js
var
isKeepScreenOn
=
true
;
var
isKeepScreenOn
=
true
;
windowClass
.
setKeepScreenOn
(
isKeepScreenOn
,
(
err
,
data
)
=>
{
windowClass
.
setKeepScreenOn
(
isKeepScreenOn
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the screen to be always on. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the screen to be always on. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the screen to be always on. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the screen to be always on. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setOutsideTouchable<sup>(deprecated)</sup>
setOutsideTouchable(touchable: boolean, callback: AsyncCallback
<
void
>
): void
### setKeepScreenOn
设置是否允许可点击子窗口以外的区域,使用callback方式作为异步方法。
setKeepScreenOn(isKeepScreenOn: boolean): Promise
<
void
>
> **说明:** 从API version 9开始废弃。
设置屏幕是否为常亮状态,使用Promise异步回调。
>
> 从 API version 7开始支持。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------- | ---- | ------------------------ |
| isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态。 |
**返回值:**
| 参数名 | 类型 | 必填 | 说明 |
| 类型 | 说明 |
| --------- | ------------------------- | ---- | ---------------- |
| ------------------- | ------------------------- |
| touchable | boolean | 是 | 设置是否可点击。 |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
js
```
js
windowClass
.
setOutsideTouchable
(
true
,
(
err
,
data
)
=>
{
var
isKeepScreenOn
=
true
;
if
(
err
.
code
)
{
let
promise
=
windowClass
.
setKeepScreenOn
(
isKeepScreenOn
);
console
.
error
(
'
Failed to set the area to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
promise
.
then
((
data
)
=>
{
return
;
console
.
info
(
'
Succeeded in setting the screen to be always on. Data:
'
+
JSON
.
stringify
(
data
))
;
}
}).
catch
((
err
)
=>
{
console
.
info
(
'
Succeeded in setting the area to be touchable. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Failed to set the screen to be always on. Cause:
'
+
JSON
.
stringify
(
err
));
})
});
```
```
### setOutsideTouchable<sup>(deprecated)</sup>
### setOutsideTouchable<sup>(deprecated)</sup>
setOutsideTouchable(touchable: boolean
): Promise
<
void
>
setOutsideTouchable(touchable: boolean
, callback: AsyncCallback
<
void
>
): void
设置是否允许可点击子窗口
以外的区域,使用Promise方式作为异步方法
。
设置是否允许可点击子窗口
之外的区域,使用callback异步回调
。
> **说明:** 从API version 9开始废弃。
> **说明:** 从API version 9开始废弃。
>
>
...
@@ -1989,58 +2071,57 @@ setOutsideTouchable(touchable: boolean): Promise<void>
...
@@ -1989,58 +2071,57 @@ setOutsideTouchable(touchable: boolean): Promise<void>
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------- | ---- | ---------------- |
| --------- | ------------------------- | ---- | ---------------- |
| touchable | boolean | 是 | 设置是否可点击。 |
| touchable | boolean | 是 | 设置是否可点击。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ----------------------------------------------- |
| Promise
<
void
>
| 以Promise形式返回结果,返回当前函数执行的结果。 |
**示例:**
**示例:**
```
js
```
js
let
promise
=
windowClass
.
setOutsideTouchable
(
true
);
windowClass
.
setOutsideTouchable
(
true
,
(
err
,
data
)
=>
{
promise
.
then
((
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
'
Succeeded in setting the area to be touchable. Data:
'
+
JSON
.
stringify
(
data
))
console
.
error
(
'
Failed to set the area to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
}).
catch
((
err
)
=>
{
return
;
console
.
error
(
'
Failed to set the area to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
}
});
console
.
info
(
'
Succeeded in setting the area to be touchable. Data:
'
+
JSON
.
stringify
(
data
));
```
})
```
### set
KeepScreenOn
### set
OutsideTouchable<sup>(deprecated)</sup>
set
KeepScreenOn(isKeepScreenOn
: boolean): Promise
<
void
>
set
OutsideTouchable(touchable
: boolean): Promise
<
void
>
设置屏幕是否为常亮状态,使用Promise异步回调。
设置是否允许可点击子窗口之外的区域,使用Promise异步回调。。
> **说明:** 从API version 9开始废弃。
>
> 从 API version 7开始支持。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名
| 类型 | 必填 | 说明
|
| 参数名
| 类型 | 必填 | 说明
|
| ---------
----- | ------- | ---- | --------
---------------- |
| ---------
| ------- | ---- |
---------------- |
|
isKeepScreenOn | boolean | 是 | 设置屏幕是否为常亮状态
。 |
|
touchable | boolean | 是 | 设置是否可点击
。 |
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isKeepScreenOn
=
true
;
let
promise
=
windowClass
.
setOutsideTouchable
(
true
);
let
promise
=
windowClass
.
setKeepScreenOn
(
isKeepScreenOn
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the area to be touchable. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the screen to be always on. Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the area to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the screen to be always on. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setPrivacyMode<sup>7+</sup>
### setPrivacyMode<sup>7+</sup>
...
@@ -2059,17 +2140,17 @@ setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): voi
...
@@ -2059,17 +2140,17 @@ setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): voi
**示例:**
**示例:**
```
js
```
js
var
isPrivacyMode
=
true
;
var
isPrivacyMode
=
true
;
windowClass
.
setPrivacyMode
(
isPrivacyMode
,
(
err
,
data
)
=>
{
windowClass
.
setPrivacyMode
(
isPrivacyMode
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window to privacy mode. 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 privacy mode. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in setting the window to privacy mode. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setPrivacyMode<sup>7+</sup>
### setPrivacyMode<sup>7+</sup>
...
@@ -2087,21 +2168,21 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void>
...
@@ -2087,21 +2168,21 @@ setPrivacyMode(isPrivacyMode: boolean): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isPrivacyMode
=
true
;
var
isPrivacyMode
=
true
;
let
promise
=
windowClass
.
setPrivacyMode
(
isPrivacyMode
);
let
promise
=
windowClass
.
setPrivacyMode
(
isPrivacyMode
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the window to privacy mode. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in setting the window to privacy mode. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set the window to privacy mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window to privacy mode. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
### setTouchable<sup>7+</sup>
### setTouchable<sup>7+</sup>
...
@@ -2120,17 +2201,17 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
...
@@ -2120,17 +2201,17 @@ setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
var
isTouchable
=
true
;
var
isTouchable
=
true
;
windowClass
.
setTouchable
(
isTouchable
,
(
err
,
data
)
=>
{
windowClass
.
setTouchable
(
isTouchable
,
(
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 be touchable. 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 be touchable. Data:
'
+
JSON
.
stringify
(
data
));
});
});
```
```
### setTouchable<sup>7+</sup>
### setTouchable<sup>7+</sup>
...
@@ -2148,110 +2229,157 @@ setTouchable(isTouchable: boolean): Promise<void>
...
@@ -2148,110 +2229,157 @@ setTouchable(isTouchable: boolean): Promise<void>
**返回值:**
**返回值:**
| 类型 | 说明
|
| 类型 | 说明 |
| ------------------- | -------------------------
----------------------
|
| ------------------- | ------------------------- |
| Promise
<
void
>
|
以Promise形式返回结果,返回当前函数执行的结果
。 |
| Promise
<
void
>
|
无返回结果的Promise对象
。 |
**示例:**
**示例:**
```
js
```
js
var
isTouchable
=
true
;
var
isTouchable
=
true
;
let
promise
=
windowClass
.
setTouchable
(
isTouchable
);
let
promise
=
windowClass
.
setTouchable
(
isTouchable
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting the window to be touchable. 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 set the window to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
## WindowStageEventType<sup>9+</sup>
## WindowStageEventType<sup>9+</sup>
WindowStage生命周期。
WindowStage生命周期。
**系统能力:**
以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
| 名称 | 默认值 | 说明 |
| 名称 | 默认值 | 说明
|
| ---------- | ------ | -------- |
| ---------- | ------ | --------
--
|
| FOREGROUND | 1 | 切到前台 |
| FOREGROUND | 1 | 切到前台
。
|
| ACTIVE | 2 | 获焦状态 |
| ACTIVE | 2 | 获焦状态
。
|
| INACTIVE | 3 | 失焦状态 |
| INACTIVE | 3 | 失焦状态
。
|
| BACKGROUND | 4 | 切到后台 |
| BACKGROUND | 4 | 切到后台
。
|
## WindowStage<sup>9+</sup>
## WindowStage<sup>9+</sup>
窗口管理器。管理各个基本窗口单元,即
[
Window
](
#window
)
实例。
下列API示例中都需在
[
onWindowStageCreate()
](
js-apis-application-ability.md#abilityonwindowstagecreate
)
函数中使用WindowStage的实例调用对应方法。
下列API示例中都需在
[
onWindowStageCreate()
](
js-apis-application-ability.md#abilityonwindowstagecreate
)
函数中使用WindowStage的实例调用对应方法。
### getMainWindow<sup>9+</sup>
### getMainWindow<sup>9+</sup>
getMainWindow(callback: AsyncCallback
<
Window
>
): void
获取该WindowStage实例下的主窗口,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调函数。返回当前WindowStage下的主窗口对象。 |
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the main window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
));
});
}
}
```
### getMainWindow<sup>9+</sup>
getMainWindow(): Promise
<
Window
>
getMainWindow(): Promise
<
Window
>
获取该WindowStage实例下的主窗口,使用Promise异步回调。
获取该WindowStage实例下的主窗口,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------------------------------- | ---------------------------------------------------------- |
| -------------------------------- | ------------------------------------------------ |
| Promise
<
[Window](#window)
>
| 以Promise形式返回结果,返回当前WindowStage下的主窗口对象。 |
| Promise
<
[Window](#window)
>
| Promise对象。返回当前WindowStage下的主窗口对象。 |
**示例:**
```
ts
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
getMainWindow
();
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the main window. Cause:
'
+
JSON
.
stringify
(
err
));
});
}
}
```
### getMainWindow<sup>9+</sup>
**示例:**
getMainWindow(callback: AsyncCallback
<
Window
>
): void
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
getMainWindow
();
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the main window. Cause:
'
+
JSON
.
stringify
(
err
));
});
}
}
```
### createSubWindow<sup>9+</sup>
获取该WindowStage实例下的主窗口,使用callback异步回调。
createSubWindow(name: string, callback: AsyncCallback
<
Window
>
): void
创建该WindowStage实例下的子窗口,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | --------------------------------------- |
| -------- | -------------------------------------- | ---- | --------------------------------------------- |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调返回当前WindowStage下的主窗口对象。 |
| name | String | 是 | 子窗口的名字。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调函数。返回当前WindowStage下的子窗口对象。 |
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
onWindowStageCreate
(
windowStage
)
{
var
windowClass
=
null
;
console
.
log
(
'
onWindowStageCreate
'
);
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
var
windowClass
=
null
;
if
(
err
.
code
)
{
windowStage
.
createSubWindow
(
"
mySubWindow
"
,
(
err
,
data
)
=>
{
console
.
error
(
'
Failed to obtain the main window. Cause:
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
)
{
return
;
console
.
error
(
'
Failed to create sub window. Cause:
'
+
JSON
.
stringify
(
err
));
}
return
;
windowClass
=
data
;
}
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
));
windowClass
=
data
;
});
console
.
info
(
'
Succeeded in create sub window. Data:
'
+
JSON
.
stringify
(
data
));
}
windowClass
.
resetSize
(
500
,
1000
);
}
});
```
}
}
```
### createSubWindow<sup>9+</sup>
### createSubWindow<sup>9+</sup>
createSubWindow(name: string): Promise
<
Window
>
createSubWindow(name: string): Promise
<
Window
>
创建该WindowStage实例下的子窗口,使用Promise异步回调。
创建该WindowStage实例下的子窗口,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -2262,127 +2390,180 @@ createSubWindow(name: string): Promise<Window>
...
@@ -2262,127 +2390,180 @@ createSubWindow(name: string): Promise<Window>
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| -------------------------------- | ------------------------------------------------- |
| -------------------------------- | ------------------------------------------------ |
| Promise
<
[Window](#window)
>
| 以Promise形式返回结果,返回当前创建的子窗口对象。 |
| Promise
<
[Window](#window)
>
| Promise对象。返回当前WindowStage下的子窗口对象。 |
**示例:**
```
ts
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
createSubWindow
(
"
mySubWindow
"
);
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in create sub window. Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create sub window. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### createSubWindow<sup>9+</sup>
**示例:**
createSubWindow(name: string, callback: AsyncCallback
<
Window
>
): void
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
createSubWindow
(
"
mySubWindow
"
);
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in create sub window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create sub window. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### getSubWindow<sup>9+</sup>
创建该WindowStage实例下的子窗口,使用callback异步回调。
getSubWindow(callback: AsyncCallback
<
Array
<
Window
>>
): void
获取该WindowStage实例下的所有子窗口,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------ |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------- |
| name | String | 是 | 子窗口的名字。 |
| callback | AsyncCallback
<
Array
<
[Window](#window)
>>
| 是 | 回调函数。返回当前WindowStage下的所有子窗口对象。 |
| callback | AsyncCallback
<
[Window](#window)
>
| 是 | 回调返回当前创建的子窗口对象。 |
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
onWindowStageCreate
(
windowStage
)
{
var
windowClass
=
null
;
console
.
log
(
'
onWindowStageCreate
'
);
windowStage
.
createSubWindow
(
"
mySubWindow
"
,
(
err
,
data
)
=>
{
var
windowClass
=
null
;
if
(
err
.
code
)
{
windowStage
.
getSubWindow
((
err
,
data
)
=>
{
console
.
error
(
'
Failed to create sub window. Cause:
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
)
{
return
;
console
.
error
(
'
Failed to obtain the sub window. Cause:
'
+
JSON
.
stringify
(
err
));
}
return
;
windowClass
=
data
;
}
console
.
info
(
'
Succeeded in create sub window. Data:
'
+
JSON
.
stringify
(
data
));
windowClass
=
data
;
windowClass
.
resetSize
(
500
,
1000
);
console
.
info
(
'
Succeeded in obtaining the sub window. Data:
'
+
JSON
.
stringify
(
data
));
});
});
}
}
}
}
```
```
### getSubWindow<sup>9+</sup>
### getSubWindow<sup>9+</sup>
getSubWindow(): Promise
<
Array
<
Window
>>
getSubWindow(): Promise
<
Array
<
Window
>>
获取该WindowStage实例下的所有子窗口,使用Promise异步回调。
获取该WindowStage实例下的所有子窗口,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
**返回值:**
| 类型 | 说明 |
| 类型 | 说明 |
| --------------------------------------------- | ------------------------------------------------------------ |
| --------------------------------------------- | ---------------------------------------------------- |
| Promise
<
Array
<
[Window](#window)
>>
| 以Promise形式返回结果,返回当前WindowStage下的所有子窗口对象。 |
| Promise
<
Array
<
[Window](#window)
>>
| Promise对象。返回当前WindowStage下的所有子窗口对象。 |
**示例:**
```
ts
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
getSubWindow
();
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the sub window. Data:
'
+
JSON
.
stringify
(
data
))
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the sub window. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### getSubWindow<sup>9+</sup>
**示例:**
getSubWindow(callback: AsyncCallback
<
Array
<
Window
>>
): void
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
getSubWindow
();
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the sub window. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the sub window. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### loadContent<sup>9+</sup>
获取该WindowStage实例下的所有子窗口,使用callback异步回调。
loadContent(path: string, storage: LocalStorage, callback: AsyncCallback
<
void
>
): void
为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用callback异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------- |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback
<
Array
<
[Window](#window)
>>
| 是 | 回调返回当前WindowStage下的所有子窗口对象。 |
| path | string | 是 | 设置加载页面的路径。 |
| storage |
[
LocalStorage
](
../ui/ui-ts-local-storage.md
)
| 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
storage
:
LocalStorage
var
windowClass
=
null
;
onWindowStageCreate
(
windowStage
)
{
windowStage
.
getSubWindow
((
err
,
data
)
=>
{
this
.
storage
=
new
LocalStorage
();
if
(
err
.
code
)
{
this
.
storage
.
setOrCreate
(
"
storageSimpleProp
"
,
121
);
console
.
error
(
'
Failed to obtain the sub window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
onWindowStageCreate
'
);
return
;
windowStage
.
loadContent
(
"
pages/page2
"
,
this
.
storage
,(
err
,
data
)
=>
{
}
if
(
err
.
code
)
{
windowClass
=
data
;
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
Succeeded in obtaining the sub window. Data:
'
+
JSON
.
stringify
(
data
));
return
;
});
}
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
}
});
```
}
}
```
### loadContent<sup>9+</sup>
loadContent(path: string, storage: LocalStorage): Promise
<
void
>
为当前WindowStage的主窗口加载与LocalStorage相关联的具体页面内容,使用Promise异步回调。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 设置加载页面的路径。 |
| storage |
[
LocalStorage
](
../ui/ui-ts-local-storage.md
)
| 是 | 存储单元,为应用程序范围内的可变状态属性和非可变状态属性提供存储。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
storage
:
LocalStorage
onWindowStageCreate
(
windowStage
)
{
this
.
storage
=
new
LocalStorage
();
this
.
storage
.
setOrCreate
(
"
storageSimpleProp
"
,
121
);
console
.
log
(
'
onWindowStageCreate
'
);
var
windowClass
=
null
;
let
promise
=
windowStage
.
loadContent
(
"
pages/page2
"
,
this
.
storage
);
promise
.
then
((
data
)
=>
{
windowClass
=
data
;
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
})
}
}
```
### loadContent<sup>9+</sup>
### loadContent<sup>9+</sup>
...
@@ -2390,7 +2571,9 @@ loadContent(path: string, callback: AsyncCallback<void>): void
...
@@ -2390,7 +2571,9 @@ loadContent(path: string, callback: AsyncCallback<void>): void
为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。
为当前WindowStage的主窗口加载具体页面内容,使用callback异步回调。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Coretype为'windowSizeChange'
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -2401,20 +2584,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
...
@@ -2401,20 +2584,21 @@ loadContent(path: string, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
onWindowStageCreate
(
windowStage
)
{
windowStage
.
loadContent
(
"
pages/page2
"
,
(
err
,
data
)
=>
{
console
.
log
(
'
onWindowStageCreate
'
);
if
(
err
.
code
)
{
windowStage
.
loadContent
(
"
pages/page2
"
,
(
err
,
data
)
=>
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
)
{
return
;
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
}
return
;
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
}
});
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
));
}
});
}
}
```
}
```
### on('windowStageEvent')<sup>9+</sup>
### on('windowStageEvent')<sup>9+</sup>
...
@@ -2422,6 +2606,8 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>
...
@@ -2422,6 +2606,8 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>
开启WindowStage生命周期变化的监听。
开启WindowStage生命周期变化的监听。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -2429,21 +2615,21 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>
...
@@ -2429,21 +2615,21 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
| callback | Callback
<
[WindowStageEventType](#windowstageeventtype9)
>
| 是 | 回调
返回监听到的信息。
|
| callback | Callback
<
[WindowStageEventType](#windowstageeventtype9)
>
| 是 | 回调
函数。返回当前的WindowStage生命周期状态。
|
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
onWindowStageCreate
(
windowStage
)
{
var
type
=
'
windowStageEvent
'
;
console
.
log
(
'
onWindowStageCreate
'
)
;
windowStage
.
on
(
type
,
(
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
));
});
});
}
}
}
}
```
```
### off('windowStageEvent')<sup>9+</sup>
### off('windowStageEvent')<sup>9+</sup>
...
@@ -2451,6 +2637,8 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g
...
@@ -2451,6 +2637,8 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g
关闭WindowStage生命周期变化的监听。
关闭WindowStage生命周期变化的监听。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -2458,19 +2646,19 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g
...
@@ -2458,19 +2646,19 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
| type | string | 是 | 监听事件,固定为'windowStageEvent',即WindowStage生命周期变化事件。 |
| callback | Callback
<
[WindowStageEventType](#windowstageeventtype9)
>
| 否 | 回调
返回监听到的信息。
|
| callback | Callback
<
[WindowStageEventType](#windowstageeventtype9)
>
| 否 | 回调
函数。返回当前的WindowStage生命周期状态。
|
**示例:**
**示例:**
```
ts
```
ts
class
myAbility
extends
Ability
{
import
Ability
from
'
@ohos.application.Ability
'
;
onWindowStageCreate
(
windowStage
)
{
class
myAbility
extends
Ability
{
console
.
log
(
'
onWindowStageCreate
'
);
onWindowStageCreate
(
windowStage
)
{
var
type
=
'
windowStageEvent
'
;
console
.
log
(
'
onWindowStageCreate
'
)
;
windowStage
.
off
(
type
);
windowStage
.
off
(
'
windowStageEvent
'
);
}
}
}
}
```
```
### setShowOnLockScreen('showOnLockScreen')<sup>9+</sup>
### setShowOnLockScreen('showOnLockScreen')<sup>9+</sup>
...
@@ -2478,6 +2666,8 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
...
@@ -2478,6 +2666,8 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
设置应用显示在锁屏之上。
设置应用显示在锁屏之上。
此接口仅可在Stage模型下使用。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
**参数:**
...
@@ -2489,6 +2679,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
...
@@ -2489,6 +2679,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void
**示例:**
**示例:**
```
ts
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
myAbility
extends
Ability
{
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
console
.
log
(
'
onWindowStageCreate
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录