From 1b52000dcb4e7c5413da325c4d38c7e057ca4e7b Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 20 Jun 2025 17:57:56 +0800 Subject: [PATCH 1/3] add code Signed-off-by: ZihaoWU --- .../apis-arkui/arkts-apis-window-Window.md | 77 +++++++++++++++++++ .../apis-arkui/arkts-apis-window-e.md | 14 ++++ .../apis-arkui/js-apis-window-sys.md | 51 ++++++++++++ 3 files changed, 142 insertions(+) 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 2ca72c72bed..8ce26545c59 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 @@ -3150,6 +3150,83 @@ try { } ``` +### on('screenshotAppEvent')20+ + +on(type: 'screenshotAppEvent', callback: Callback<ScreenshotEventType>): void + +开启截屏事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | +| callback | Callback<[ScreenshotEventType](#screenshoteventtype20)> | 是 | 回调函数。返回当前的截图事件类型。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service works abnormally. | + +**示例:** + +```ts +try { + windowClass.on('screenshotAppEvent', (data) => { + console.info(`screenshot happened. Event: ${data}`); + }); +} catch (exception) { + console.error(`Failed to register callback. Cause code: ${exception.code}, message: ${exception.message}`); +} +``` + +### off('screenshotAppEvent')20+ + +off(type: 'screenshotAppEvent', callback?: Callback<ScreenshotEventType>): void + +关闭截屏事件的监听。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | +| callback | Callback<[ScreenshotEventType](#screenshoteventtype20)> | 否 | 回调函数。返回当前的截图事件类型。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口截图事件的监听。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| ------- | ------------------------------ | +| 1300002 | This window state is abnormal. | +| 1300003 | This window manager service works abnormally. | + +**示例:** + +```ts +const callback = (eventType: window.ScreenshotEventType) => { + // ... +} +try { + // 通过on接口开启监听 + windowClass.on('screenshotAppEvent', callback); + // 关闭指定callback的监听 + windowClass.off('screenshotAppEvent', callback); + // 如果通过on开启多个callback进行监听,同时关闭所有监听: + windowClass.off('screenshotAppEvent'); +} catch (exception) { + console.error(`Failed to unregister callback. Cause code: ${exception.code}, message: ${exception.message}`); +} + ### on('dialogTargetTouch')10+ on(type: 'dialogTargetTouch', callback: Callback<void>): void diff --git a/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-e.md b/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-e.md index e6ceaf95a7c..5b3ba5ec2dc 100644 --- a/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-e.md +++ b/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window-e.md @@ -251,3 +251,17 @@ WindowStage生命周期。 | -------------------- | ------ | ---------- | | WINDOW_MODALITY | 0 | 模态子窗类型为模窗口子窗,当仅需要其父级窗口不响应用户操作时,可选此参数。 | | APPLICATION_MODALITY | 1 | 模态子窗类型为模应用子窗,除其父级窗口外还需要该应用其他实例的窗口不响应用户操作时,可选此参数。
此接口仅支持在2in1设备下使用。 | + +## ScreenshotEventType20+ + +截图事件类型枚举。 + +**系统能力:** SystemCapability.Window.SessionManager + +| 名称 | 值 | 说明 | +| ------ | ---- | --------------------- | +| SYSTEM_SCREENSHOT | 0 | 系统截图。 | +| SYSTEM_SCREENSHOT_ABORT | 1 | 系统截图中止。 | +| SCROLL_SHOT_START | 2 | 滚动截图开始。 | +| SCROLL_SHOT_END | 3 | 滚动截图结束。 | +| SCROLL_SHOT_ABORT | 4 | 滚动截图开始中止。 | 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 7d2f8644ff9..06c0562cbfc 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 @@ -968,6 +968,57 @@ try { } ``` +## window.notifyScreenshotEvent20+ + +notifyScreenshotEvent(eventType: ScreenshotEventType): Promise<void> + +通知截屏事件,使用Promise异步回调。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ----- | ------------ | +| eventType | [ScreenshotEventType](js-apis-window.md#screenshoteventtype20) | 是 | 截屏事件类型。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------- | ------------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------------------------------------------- | +| 202 | Permission verification failed. A non-system application calls a system API. | +| 1300003 | This window manager service works abnormally. | +| 1300016 | Parameter error. Possible cause: 1. Invalid parameter range. 2. Invalid parameter length. 3. Incorrect parameter format. | + +**示例:** + +```ts +import { BusinessError } from '@kit.BasicServicesKit'; +import { image } from '@kit.ImageKit'; + +try { + let eventType: ScreenshotEventType = window.ScreenshotEventType.SYSTEM_SCREENSHOT; + let promise = window.notifyScreenshotEvent(eventType); + promise.then(() => { + console.info(`Succeeded in notify screenshot event type.`); + }).catch((err: BusinessError) =>{ + console.error(`Failed to notify screenshot event type. Cause code: ${err.code}, message: ${err.message}`); + }); +} catch (exception) { + console.error(`Failed to notify screenshot event type. Cause code: ${exception.code}, message: ${exception.message}`); +} +``` + ## window.getTopNavDestinationName20+ getTopNavDestinationName(windowId: number): Promise<string> -- Gitee From 93835dc9cada9f948a2195634fd1926a6432b349 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 20 Jun 2025 18:02:03 +0800 Subject: [PATCH 2/3] add code Signed-off-by: ZihaoWU --- .../reference/apis-arkui/arkts-apis-window-Window.md | 4 ++-- .../reference/apis-arkui/js-apis-window-sys.md | 2 +- 2 files changed, 3 insertions(+), 3 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 8ce26545c59..f46a454d4ef 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 @@ -3163,7 +3163,7 @@ on(type: 'screenshotAppEvent', callback: Callback<ScreenshotEventType>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | -| callback | Callback<[ScreenshotEventType](#screenshoteventtype20)> | 是 | 回调函数。返回当前的截图事件类型。 | +| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20> | 是 | 回调函数。返回当前的截图事件类型。 | **错误码:** @@ -3199,7 +3199,7 @@ off(type: 'screenshotAppEvent', callback?: Callback<ScreenshotEventType>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | -| callback | Callback<[ScreenshotEventType](#screenshoteventtype20)> | 否 | 回调函数。返回当前的截图事件类型。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口截图事件的监听。 | +| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20> | 否 | 回调函数。返回当前的截图事件类型。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口截图事件的监听。 | **错误码:** 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 06c0562cbfc..8a37f706881 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 @@ -982,7 +982,7 @@ notifyScreenshotEvent(eventType: ScreenshotEventType): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ----- | ------------ | -| eventType | [ScreenshotEventType](js-apis-window.md#screenshoteventtype20) | 是 | 截屏事件类型。 | +| eventType | [ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20) | 是 | 截屏事件类型。 | **返回值:** -- Gitee From 6eb42ff97abef6eee1e7ed1da97d939b062786d9 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 20 Jun 2025 18:03:04 +0800 Subject: [PATCH 3/3] add code Signed-off-by: ZihaoWU --- .../reference/apis-arkui/arkts-apis-window-Window.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f46a454d4ef..8e574fc35ed 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 @@ -3163,7 +3163,7 @@ on(type: 'screenshotAppEvent', callback: Callback<ScreenshotEventType>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | -| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20> | 是 | 回调函数。返回当前的截图事件类型。 | +| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20)> | 是 | 回调函数。返回当前的截图事件类型。 | **错误码:** @@ -3199,7 +3199,7 @@ off(type: 'screenshotAppEvent', callback?: Callback<ScreenshotEventType>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------------------------ | | type | string | 是 | 监听事件,固定为'screenshotAppEvent',即截屏事件。 | -| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20> | 否 | 回调函数。返回当前的截图事件类型。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口截图事件的监听。 | +| callback | Callback<[ScreenshotEventType](arkts-apis-window-e.md#screenshoteventtype20)> | 否 | 回调函数。返回当前的截图事件类型。若传入参数,则关闭该监听。若未传入参数,则关闭所有窗口截图事件的监听。 | **错误码:** -- Gitee