From db6bacfde3f1972dedaec659bbbddbe8c5220924 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Thu, 5 Feb 2026 11:38:23 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F=E7=95=8C?= =?utf8?q?=E9=9D=A2=E6=81=AF=E5=B1=8F=E5=A4=B1=E7=84=A6=EF=BC=8C=E8=A1=A8?= =?utf8?q?=E5=86=A0=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/system/include/SystemView.h | 3 +++ .../nativeui/system/src/SystemPresenter.cpp | 4 ++++ .../nativeapp/nativeui/system/src/SystemView.cpp | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h index d6eb50d8d..77a12d7de 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h @@ -94,6 +94,8 @@ namespace OHOS bool CheckViewParam(int16_t hideView, int16_t showView); void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetSystemScrollView(int ViewId); + /** 息屏再亮屏后表冠失效时,为当前显示的滚动视图重新申请焦点(含系统主界面、关于手表等所有 subview) */ + void RequestFocusForCurrentView(); private: SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; // 关于手表 @@ -121,6 +123,7 @@ namespace OHOS UIImageView *NeedToUpdateImage{nullptr}; // 提示需要系统更新的icon图片 UIImageView *temp{nullptr}; bool viewInitStatus{false}; + int16_t currentShowViewId_{SYSTEMVIEW}; // 当前显示的 subview,息屏亮屏后用于恢复表冠焦点 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp index 1bf344a1a..c1c990eaf 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -52,6 +52,10 @@ namespace OHOS void SystemPresenter::OnResume() { RootView::GetInstance()->SetOnKeyActListener(this); + SystemView *p_SystemView = SystemView::GetInstance(); + if (p_SystemView != nullptr) { + p_SystemView->RequestFocusForCurrentView(); + } } static uint32_t time = 0; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp index 7275990c0..5f26afa78 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp @@ -353,12 +353,22 @@ namespace OHOS { NeedToUpdateImageinit(); } + currentShowViewId_ = SYSTEMVIEW; AddViewToRootContainer(SystemScrollView[SYSTEMVIEW]); } - + void SystemView::RequestFocusForCurrentView() + { + // 系统主界面、关于手表等任意当前 subview 息屏亮屏后恢复表冠焦点 + if (currentShowViewId_ >= 0 && currentShowViewId_ < MAX_SYSTEMVIEWID && + SystemScrollView[currentShowViewId_] != nullptr) { + SystemScrollView[currentShowViewId_]->RequestFocus(); + } + } + + // 0.跳转到系统视图,其他视图都市通过这个视图跳转 bool SystemView::ChangeToSystemView(int16_t thisView) { @@ -542,6 +552,10 @@ namespace OHOS SystemScrollView[hideView]->SetVisible(false); ClickFunc(showView); SystemScrollView[showView]->SetVisible(true); + currentShowViewId_ = showView; + if (SystemScrollView[showView] != nullptr) { + SystemScrollView[showView]->RequestFocus(); + } Draw(); } -- 2.17.1