From 6dae2ee792d828b828f53b310e86e8a6e779f467 Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Tue, 10 Mar 2026 20:10:21 +0800 Subject: [PATCH] fix: set focus to search edit when launcher becomes visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the launcher is shown, the keyboard focus remains on the root InputEventItem instead of the search edit. This causes two issues: 1. The cursor does not appear in the search bar on each open. 2. The IME candidate window is not visible during the preedit phase (e.g. typing pinyin), because InputEventItem is not a text input widget and cannot provide cursor geometry for IME positioning. Fix by calling forceActiveFocus() on the search edit when the launcher becomes visible, for both windowed and fullscreen modes. 修复启动器显示时搜索框未获得焦点的问题。启动器打开时键盘焦点停留在根节点 InputEventItem 上而非搜索框,导致光标不在搜索栏,且中文输入法预编辑阶段 (如拼音输入时)候选框不可见。在启动器可见时对搜索框调用 forceActiveFocus() 以修复此问题,同时修复窗口模式和全屏模式。 PMS: BUG-301743 --- qml/FullscreenFrame.qml | 6 +++++- qml/windowed/WindowedFrame.qml | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qml/FullscreenFrame.qml b/qml/FullscreenFrame.qml index df6c267e..5829386b 100644 --- a/qml/FullscreenFrame.qml +++ b/qml/FullscreenFrame.qml @@ -883,8 +883,12 @@ InputEventItem { Connections { target: LauncherController function onVisibleChanged() { + if (LauncherController.visible) { + searchEdit.forceActiveFocus() + return + } + // only do these clean-up steps on launcher get hide - if (LauncherController.visible) return // clear searchEdit text searchEdit.text = "" if (listviewPage.currentItem) { diff --git a/qml/windowed/WindowedFrame.qml b/qml/windowed/WindowedFrame.qml index fc763c32..f4bee7db 100644 --- a/qml/windowed/WindowedFrame.qml +++ b/qml/windowed/WindowedFrame.qml @@ -303,9 +303,12 @@ InputEventItem { Connections { target: LauncherController function onVisibleChanged() { - // only do these clean-up steps on launcher get hide - if (LauncherController.visible) return + if (LauncherController.visible) { + bottomBar.searchEdit.forceActiveFocus() + return + } + // only do these clean-up steps on launcher get hide // clear searchEdit text bottomBar.searchEdit.text = "" // reset(remove) keyboard focus