From c8cb9d2aad2130ba53c2f47f9a4d5f3adb14f55b Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Tue, 1 Jul 2025 15:18:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=BB=E7=AA=97=E5=8F=A3=E6=94=AF?= =?UTF-8?q?=E6=8C=81z=E5=BA=8F=E8=B0=83=E6=95=B4=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- .../apis-arkui/js-apis-window-sys.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md index 28f7fdd19d2..8b7cb96c010 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md @@ -2795,6 +2795,85 @@ export default class EntryAbility extends UIAbility { } ``` +### raiseMainWindowAboveTarget20+ + +raiseMainWindowAboveTarget(windowId: number): Promise<void> + +将同应用下的主窗口的z序调整至另一个主窗口之上。使用Promise异步回调。 + +仅支持2in1设备上显示在锁屏之下的非模态主窗口。 + +调用该接口调整当前主窗口z序后,若当前主窗口抬升超过焦点窗口,则当前主窗口自动获焦;若当前主窗口是焦点窗口,且层级降低,则z序最高的主窗自动获焦。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.Window.SessionManager + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| windowId | number | 是 | 目标子窗口的id,通过[getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9)接口获取到[properties](arkts-apis-window-i.md#windowproperties)后,再通过properties.id获取。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 202 | Permission verification failed. A non-system application calls a system API. | +| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service works abnormally. | +| 1300004 | Unauthorized operation. | +| 1300016 | Parameter error. Possible cause: 1. Invalid Parameter range. 2. Invalid parameter length. | + +**示例:** + +```ts +// EntryAbility.ets +import { window } from '@kit.ArkUI'; +import { UIAbility } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class EntryAbility extends UIAbility { + // ... + onWindowStageCreate(windowStage: window.WindowStage): void { + console.info('onWindowStageCreate'); + let windowClass: window.Window; + // 创建子窗 + try { + windowStage.createSubWindow("testSubWindow").then((data) => { + if (data == null) { + console.error("Failed to create the subWindow. Cause: The data is empty"); + return; + } + windowClass = data; + windowClass.showWindow().then(() => { + // windowClass的获取需放在targetWindow之上 + let targetWindow: window.Window = windowClass; + let properties = targetWindow.getWindowProperties(); + let targetId = properties.id; + windowClass.raiseAboveTarget(targetId).then(()=> { + console.info('Succeeded in raising the subWindow to target subWindow top.'); + }).catch((err: BusinessError)=>{ + console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); + }); + }); + }); + } catch (exception) { + console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); + } + } +} +``` + ### setRaiseByClickEnabled10+ setRaiseByClickEnabled(enable: boolean, callback: AsyncCallback<void>): void -- Gitee From 51694b40c043f103cf0488ffd593380d99bf20a9 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Tue, 1 Jul 2025 15:21:55 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- .../reference/apis-arkui/js-apis-window-sys.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md index 8b7cb96c010..eb2824f3568 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md @@ -2799,11 +2799,11 @@ export default class EntryAbility extends UIAbility { raiseMainWindowAboveTarget(windowId: number): Promise<void> -将同应用下的主窗口的z序调整至另一个主窗口之上。使用Promise异步回调。 +将主窗口的Z序调整至同应用下的另一个主窗口之上,子窗口的Z序会跟随所属主窗口变动。使用Promise异步回调。 -仅支持2in1设备上显示在锁屏之下的非模态主窗口。 +仅支持2in1设备上显示在锁屏之下的非置顶主窗口调用。 -调用该接口调整当前主窗口z序后,若当前主窗口抬升超过焦点窗口,则当前主窗口自动获焦;若当前主窗口是焦点窗口,且层级降低,则z序最高的主窗自动获焦。 +调用该接口抬升应用主窗口高于焦点窗口,则被抬升应用主窗口自动获焦;调用该接口降低焦点窗口,则Z序最高的应用主窗口自动获焦 **系统接口:** 此接口为系统接口。 -- Gitee From 3926dd52dffe6cc840560307b3239ebd5407b091 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Tue, 1 Jul 2025 15:44:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- .../application-dev/reference/apis-arkui/js-apis-window-sys.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md index eb2824f3568..dccb5f2ce42 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md @@ -2813,7 +2813,7 @@ raiseMainWindowAboveTarget(windowId: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | -| windowId | number | 是 | 目标子窗口的id,通过[getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9)接口获取到[properties](arkts-apis-window-i.md#windowproperties)后,再通过properties.id获取。 | +| windowId | number | 是 | 目标主窗口的id,该参数为整数,通过[getWindowProperties](arkts-apis-window-Window.md#getwindowproperties9)接口获取到[properties](arkts-apis-window-i.md#windowproperties)后,再通过properties.id获取。 | **返回值:** -- Gitee From 1ed5b60377c25179bd2192787745692b0ae83aa4 Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Thu, 3 Jul 2025 17:15:40 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E7=BB=86=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- .../application-dev/reference/apis-arkui/js-apis-window-sys.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md index dccb5f2ce42..4c72f02acae 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md @@ -2801,7 +2801,7 @@ raiseMainWindowAboveTarget(windowId: number): Promise<void> 将主窗口的Z序调整至同应用下的另一个主窗口之上,子窗口的Z序会跟随所属主窗口变动。使用Promise异步回调。 -仅支持2in1设备上显示在锁屏之下的非置顶主窗口调用。 +仅支持2in1设备的系统应用主窗口调用,传入目标主窗口的id,调用窗口和目标窗口需满足:同应用进程、显示在同一屏幕、低于锁屏、非置顶主窗、非模态主窗且无模应用子窗。 调用该接口抬升应用主窗口高于焦点窗口,则被抬升应用主窗口自动获焦;调用该接口降低焦点窗口,则Z序最高的应用主窗口自动获焦 -- Gitee From 154f37c25e70bc91978079dbf15e1916ae018b7e Mon Sep 17 00:00:00 2001 From: Hayden Lee Date: Thu, 3 Jul 2025 17:20:35 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hayden Lee --- .../apis-arkui/js-apis-window-sys.md | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md index 4c72f02acae..4779ab62b5e 100644 --- a/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md +++ b/zh-cn/application-dev/reference/apis-arkui/js-apis-window-sys.md @@ -2846,30 +2846,14 @@ export default class EntryAbility extends UIAbility { // ... onWindowStageCreate(windowStage: window.WindowStage): void { console.info('onWindowStageCreate'); - let windowClass: window.Window; - // 创建子窗 - try { - windowStage.createSubWindow("testSubWindow").then((data) => { - if (data == null) { - console.error("Failed to create the subWindow. Cause: The data is empty"); - return; - } - windowClass = data; - windowClass.showWindow().then(() => { - // windowClass的获取需放在targetWindow之上 - let targetWindow: window.Window = windowClass; - let properties = targetWindow.getWindowProperties(); - let targetId = properties.id; - windowClass.raiseAboveTarget(targetId).then(()=> { - console.info('Succeeded in raising the subWindow to target subWindow top.'); - }).catch((err: BusinessError)=>{ - console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); - }); - }); + let targetId: number = 102; + windowStage.getMainWindow().then((mainWindow) => { + mainWindow.raiseMainWindowAboveTarget(targetId).then(() => { + console.info('Succeeded in raising the main window above target.'); + }).catch((err: BusinessError) => { + console.error(`Failed to raise the main window above target. Cause code: ${err.code}, message: ${err.message}`); }); - } catch (exception) { - console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); - } + }); } } ``` -- Gitee