From 8a4d16b65bd173bc8fc3c5a1c0d86d596cf99289 Mon Sep 17 00:00:00 2001 From: xuhangqi Date: Thu, 24 Jul 2025 10:50:06 +0800 Subject: [PATCH] Refactor overload ohos.window1 Issue: https://gitee.com/openharmony/interface_sdk-js/issues/ICOFWM Signed-off-by: xuhangqi Change-Id: If87f5ca3bda81fcc115d9a0dc3f10492801e41ff --- .../window_stage_ani/ets/@ohos.window.ets | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets b/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets index 82609185e5..da38507f1b 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets @@ -2707,7 +2707,7 @@ export class WindowInternal implements Window { }); } - public setWindowFocusable(isFocusable: boolean): Promise { + public setWindowFocusableReturnPromise(isFocusable: boolean): Promise { return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowFocusableSync(this.nativeObj, isFocusable); @@ -2719,7 +2719,7 @@ export class WindowInternal implements Window { }); } - public setWindowFocusable(isFocusable: boolean, callback: AsyncCallback): void { + public setWindowFocusableWithCallback(isFocusable: boolean, callback: AsyncCallback): void { taskpool.execute((): void => { this.setWindowFocusableSync(this.nativeObj, isFocusable); }).then((ret: NullishType) => { @@ -2729,6 +2729,8 @@ export class WindowInternal implements Window { }); } + overload setWindowFocusable { setWindowFocusableWithCallback, setWindowFocusableReturnPromise }; + public keepKeyboardOnFocus(keepKeyboardFlag: boolean): void { this.keepKeyboardOnFocusSync(this.nativeObj, keepKeyboardFlag); } @@ -2961,8 +2963,9 @@ export interface Window { hideWithAnimation(): Promise; showWithAnimation(callback: AsyncCallback): void; showWithAnimation(): Promise; - setWindowFocusable(isFocusable: boolean): Promise; - setWindowFocusable(isFocusable: boolean, callback: AsyncCallback): void; + setWindowFocusableReturnPromise(isFocusable: boolean): Promise; + setWindowFocusableWithCallback(isFocusable: boolean, callback: AsyncCallback): void; + overload setWindowFocusable { setWindowFocusableWithCallback, setWindowFocusableReturnPromise }; keepKeyboardOnFocus(enable: boolean): void; setWindowTouchable(isTouchable: boolean): Promise setWindowTouchable(isTouchable: boolean, callback: AsyncCallback): void @@ -2995,7 +2998,7 @@ native function offSync(nativeObj: long, type: string, callback?: object): void; native function shiftAppWindowFocusSync(nativeObj: long, sourceWindowId: int, targetWindowId: int): void; native function createWindowSync(nativeObj: long, config: Configuration): Window; -export function getLastWindow(ctx: BaseContext): Promise { +export function getLastWindowReturnPromise(ctx: BaseContext): Promise { return new Promise((resolve: (value: Window) => void, reject: (error: BusinessError) => void) => { taskpool.execute((): Window => { hilog.info(DOMAIN, TAG, 'getLastWindow, ctx:' + ctx); @@ -3008,7 +3011,7 @@ export function getLastWindow(ctx: BaseContext): Promise { }); } -export function getLastWindow(ctx: BaseContext, callback: AsyncCallback): void { +export function getLastWindowWithCallback(ctx: BaseContext, callback: AsyncCallback): void { taskpool.execute((): Window => { hilog.info(DOMAIN, TAG, 'getLastWindow, ctx:' + ctx); return getLastWindowSync(nativeObj, ctx); @@ -3019,6 +3022,8 @@ export function getLastWindow(ctx: BaseContext, callback: AsyncCallback) }); } +export overload getLastWindow { getLastWindowWithCallback, getLastWindowReturnPromise }; + export function createWindow(config: Configuration): Promise { return new Promise((resolve: (value: Window) => void, reject: (error: BusinessError) => void ) => { taskpool.execute((): Window => { -- Gitee