提交 aeef562c 编写于 作者: L leafly2021

add window resize limit

Signed-off-by: Nleafly2021 <figo.yefei@huawei.com>
Change-Id: I656175a443abb452e6c4b98f311bbfabee5a2ff0
上级 bd4b5132
...@@ -778,9 +778,9 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v ...@@ -778,9 +778,9 @@ on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): v
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | | type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 是 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:** **示例:**
...@@ -807,9 +807,9 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;) ...@@ -807,9 +807,9 @@ off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;)
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 | | type | string | 是 | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
| callback | Callback&lt;[SystemBarTintState](#systembartintstate)&gt; | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 | | callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 否 | 回调函数。返回当前的状态栏、导航栏信息集合。 |
**示例:** **示例:**
...@@ -1638,6 +1638,12 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1638,6 +1638,12 @@ resize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): void
改变当前窗口大小,使用callback异步回调。 改变当前窗口大小,使用callback异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -1679,6 +1685,12 @@ resize(width: number, height: number): Promise&lt;void&gt; ...@@ -1679,6 +1685,12 @@ resize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。 改变当前窗口大小,使用Promise异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core **系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:** **参数:**
...@@ -4369,6 +4381,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v ...@@ -4369,6 +4381,12 @@ resetSize(width: number, height: number, callback: AsyncCallback&lt;void&gt;): v
改变当前窗口大小,使用callback异步回调。 改变当前窗口大小,使用callback异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
> **说明:** > **说明:**
> >
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。 > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9)。
...@@ -4401,6 +4419,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt; ...@@ -4401,6 +4419,12 @@ resetSize(width: number, height: number): Promise&lt;void&gt;
改变当前窗口大小,使用Promise异步回调。 改变当前窗口大小,使用Promise异步回调。
应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
设置的宽度与高度受到此约束限制。
> **说明:** > **说明:**
> >
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。 > 从 API version 7开始支持,从API version 9开始废弃,推荐使用[resize()](#resize9-1)。
......
...@@ -136,9 +136,7 @@ ...@@ -136,9 +136,7 @@
当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用`destroy`接口销毁子窗口。 当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用`destroy`接口销毁子窗口。
```js ```js
// 销毁子窗口。当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用destroy接口销毁子窗口,此处以监听窗口区域外的点击事件实现子窗口的销毁。 // 销毁子窗口。当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用destroy接口销毁子窗口。
windowClass.on('touchOutside', () => {
console.info('touch outside');
windowClass.destroy((err, data) => { windowClass.destroy((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err)); console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err));
...@@ -146,7 +144,6 @@ ...@@ -146,7 +144,6 @@
} }
console.info('Succeeded in destroying the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the subwindow. Data: ' + JSON.stringify(data));
}); });
});
``` ```
......
...@@ -127,11 +127,12 @@ class MainAbility extends Ability { ...@@ -127,11 +127,12 @@ class MainAbility extends Ability {
```ts ```ts
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
let windowStage_ = null;
let sub_windowClass = null;
class MainAbility extends Ability { class MainAbility extends Ability {
onWindowStageCreate(windowStage) { showSubWindow() {
// 1.创建应用子窗口。 // 1.创建应用子窗口。
let sub_windowClass = null; windowStage_.createSubWindow("mySubWindow", (err, data) => {
windowStage.createSubWindow("mySubWindow", (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));
return; return;
...@@ -139,7 +140,7 @@ class MainAbility extends Ability { ...@@ -139,7 +140,7 @@ class MainAbility extends Ability {
sub_windowClass = data; sub_windowClass = data;
console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data));
// 1.获取已创建的应用子窗口。 // 1.获取已创建的应用子窗口。
windowStage.getSubWindow((err, data) => { windowStage_.getSubWindow((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain the subWindow. Cause:' + JSON.stringify(err)); console.error('Failed to obtain the subWindow. Cause:' + JSON.stringify(err));
return; return;
...@@ -178,6 +179,10 @@ class MainAbility extends Ability { ...@@ -178,6 +179,10 @@ class MainAbility extends Ability {
console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data));
}); });
}); });
})
}
destroySubWindow() {
// 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。 // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
sub_windowClass.destroy((err, data) => { sub_windowClass.destroy((err, data) => {
if (err.code) { if (err.code) {
...@@ -186,7 +191,17 @@ class MainAbility extends Ability { ...@@ -186,7 +191,17 @@ class MainAbility extends Ability {
} }
console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data));
}); });
}) }
onWindowStageCreate(windowStage) {
windowStage_ = windowStage;
// 开发者可以在适当的时机,如主窗口上按钮点击事件等,创建子窗口。并不一定需要在onWindowStageCreate调用,这里仅作展示
this.showSubWindow();
}
onWindowStageDestroy() {
// 开发者可以在适当的时机,如子窗口上点击关闭按钮等,销毁子窗口。并不一定需要在onWindowStageDestroy调用,这里仅作展示
this.destroySubWindow();
} }
}; };
``` ```
......
...@@ -65,4 +65,8 @@ OpenHarmony的窗口模块将窗口界面分为系统窗口、应用窗口两种 ...@@ -65,4 +65,8 @@ OpenHarmony的窗口模块将窗口界面分为系统窗口、应用窗口两种
## 约束与限制 ## 约束与限制
在FA模型下,不支持系统窗口的相关开发。 - 在FA模型下,不支持系统窗口的相关开发。
- 应用主窗口与子窗口存在大小限制,宽度范围:[320, 2560],高度范围:[240, 2560],单位为vp。
- 系统窗口存在大小限制,宽度范围:[0, 2560],高度范围:[0, 2560],单位为vp。
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册