From 485e82184d1badad0124ecfc75e445ee2978910f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E4=BA=9A=E8=8A=B3?= Date: Wed, 18 Jun 2025 02:50:15 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-Window.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 葛亚芳 --- .../apis-arkui/arkts-apis-window-Window.md | 167 +++++++++--------- 1 file changed, 84 insertions(+), 83 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-Window.md b/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-Window.md index 5788b604046..517f1573d87 100644 --- a/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-Window.md +++ b/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-Window.md @@ -7736,7 +7736,7 @@ startMoving(): Promise<void> 开始移动窗口,使用Promise异步回调。 -仅在[onTouch](./arkui-ts/ts-universal-events-touch.md#ontouch)事件(其中,事件类型必须为TouchType.Down)的回调方法中调用此接口才会有移动效果,成功调用此接口后,窗口将跟随鼠标或触摸点移动。 +仅在[onTouch](./arkui-ts/ts-universal-events-touch.md#ontouch对象说明)事件(其中,事件类型必须为TouchType.Down)的回调方法中调用此接口才会有移动效果,成功调用此接口后,窗口将跟随鼠标或触摸点移动。 手机设备上对子窗、系统窗口生效。 @@ -7810,7 +7810,7 @@ startMoving(offsetX: number, offsetY: number): Promise<void> 在同应用内窗口分合后,且鼠标保持按下状态直接移动新窗口,如果此时鼠标快速移动,窗口移动时鼠标可能会在窗口外。可以使用本接口指定窗口移动时鼠标在窗口内的位置,先移动窗口到鼠标位置,再开始移动窗口。 -仅在[onTouch](./arkui-ts/ts-universal-events-touch.md#touchevent)事件(其中,事件类型必须为TouchType.Down)的回调方法中调用此接口才会有移动效果,成功调用此接口后,窗口将跟随鼠标移动。 +仅在[onTouch](./arkui-ts/ts-universal-events-touch.md#touchevent对象说明)事件(其中,事件类型必须为TouchType.Down)的回调方法中调用此接口才会有移动效果,成功调用此接口后,窗口将跟随鼠标移动。 此接口仅可在2in1设备下使用。 @@ -8659,83 +8659,6 @@ export default class EntryAbility extends UIAbility { } ``` -### setWindowSystemBarProperties(deprecated) - -setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void - -设置主窗口三键导航栏、状态栏的属性,使用callback异步回调,该接口在2in1设备上调用不生效。 - -子窗口调用后不生效。 - -> **说明:** -> -> 从API version 9开始支持,从API version 12开始废弃,推荐使用Promise方式的[setWindowSystemBarProperties](#setwindowsystembarproperties9)。 - -**系统能力:** SystemCapability.WindowManager.WindowManager.Core - -**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------------- | ------------------------------------------- | ---- | ---------------------- | -| systemBarProperties | [SystemBarProperties](arkts-apis-window-i.md#systembarproperties) | 是 | 三键导航栏、状态栏的属性。 | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**错误码:** - -以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 - -| 错误码ID | 错误信息 | -| -------- | ------------------------------------------------------------------------------------------------------------ | -| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | -| 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. | - -**示例:** - -```ts -// EntryAbility.ets -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 | undefined = undefined; - windowStage.getMainWindow((err: BusinessError, data) => { - const errCode: number = err.code; - if (errCode) { - console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - return; - } - windowClass = data; - let SystemBarProperties: window.SystemBarProperties = { - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - //以下两个属性从API Version8开始支持 - statusBarContentColor: '#ffffff', - navigationBarContentColor: '#00ffff' - }; - try { - windowClass.setWindowSystemBarProperties(SystemBarProperties, (err: BusinessError) => { - const errCode: number = err.code; - if (errCode) { - console.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); - return; - } - console.info('Succeeded in setting the system bar properties.'); - }); - } catch (exception) { - console.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); - } - }); - } -} -``` - ### setSubWindowZLevel18+ setSubWindowZLevel(zLevel: number): Promise<void> @@ -8861,6 +8784,84 @@ export default class EntryAbility extends UIAbility { } ``` + +### setWindowSystemBarProperties(deprecated) + +setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void + +设置主窗口三键导航栏、状态栏的属性,使用callback异步回调,该接口在2in1设备上调用不生效。 + +子窗口调用后不生效。 + +> **说明:** +> +> 从API version 9开始支持,从API version 12开始废弃,推荐使用Promise方式的[setWindowSystemBarProperties](#setwindowsystembarproperties9)。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------------- | ------------------------------------------- | ---- | ---------------------- | +| systemBarProperties | [SystemBarProperties](arkts-apis-window-i.md#systembarproperties) | 是 | 三键导航栏、状态栏的属性。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------------------------------------------------------ | +| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | +| 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. | + +**示例:** + +```ts +// EntryAbility.ets +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 | undefined = undefined; + windowStage.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + windowClass = data; + let SystemBarProperties: window.SystemBarProperties = { + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version8开始支持 + statusBarContentColor: '#ffffff', + navigationBarContentColor: '#00ffff' + }; + try { + windowClass.setWindowSystemBarProperties(SystemBarProperties, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`); + return; + } + console.info('Succeeded in setting the system bar properties.'); + }); + } catch (exception) { + console.error(`Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`); + } + }); + } +} +``` + ### setWindowSystemBarEnable(deprecated) setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallback<void>): void @@ -9503,7 +9504,7 @@ setFullScreen(isFullScreen: boolean): Promise<void> > **说明:** > -> 从API version 6开始支持,从API version 9开始废弃,推荐联合使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)和[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)实现全屏。 +> 从API version 6开始支持,从API version 9开始废弃,推荐联合使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)和[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)实现全屏。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -9614,7 +9615,7 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> > **说明:** > -> 从API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9-1)。 +> 从API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowLayoutFullScreen()](#setwindowlayoutfullscreen9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -9727,7 +9728,7 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> > **说明:** > -> 从API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9-1)。 +> 从API version 7开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarEnable()](#setwindowsystembarenable9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -9846,7 +9847,7 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi > **说明:** > -> 从API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9-1)。 +> 从API version 6开始支持,从API version 9开始废弃,推荐使用[setWindowSystemBarProperties()](#setwindowsystembarproperties9)。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -- Gitee