From e5d24389b4f4c5143f1e0f40b59df7e0dd60313a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Fri, 1 May 2026 23:17:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(shortcuts):=20=E6=B7=BB=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=BF=AB=E6=8D=B7=E9=94=AE=20Ctrl+N/S/F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ctrl+N: 新建路径 - Ctrl+S: 保存(确定) - Ctrl+F: 聚焦搜索框 - 对话框级 K_ANY 回调,列表级 K_ANY 保持 Ctrl+Z/Y/DEL Co-Authored-By: Claude Opus 4.7 --- include/controller/callbacks.h | 1 + src/controller/callbacks_sys.c | 23 +++++++++++++++++++++++ src/ui/main_window.c | 1 + 3 files changed, 25 insertions(+) diff --git a/include/controller/callbacks.h b/include/controller/callbacks.h index e51c7e1..1205c2b 100644 --- a/include/controller/callbacks.h +++ b/include/controller/callbacks.h @@ -33,6 +33,7 @@ int list_dropfiles_cb(Ihandle *self, const char *filename, int num, int x, int y // 键盘按键回调 int list_k_any_cb(Ihandle *self, int c); +int dlg_k_any_cb(Ihandle *self, int c); // 载入数据与更新UI void load_all_paths(void); diff --git a/src/controller/callbacks_sys.c b/src/controller/callbacks_sys.c index d717ac2..f1c8de8 100644 --- a/src/controller/callbacks_sys.c +++ b/src/controller/callbacks_sys.c @@ -202,3 +202,26 @@ int btn_help_cb(Ihandle *self) return IUP_DEFAULT; } + +// 对话框全局快捷键回调 +int dlg_k_any_cb(Ihandle *self, int c) +{ + if (c == K_cN) // Ctrl+N 新建 + { + btn_new_cb(self); + return IUP_IGNORE; + } + if (c == K_cS) // Ctrl+S 保存 + { + btn_ok_cb(self); + return IUP_IGNORE; + } + if (c == K_cF) // Ctrl+F 聚焦搜索框 + { + Ihandle *txt_search = IupGetDialogChild(self, CTRL_TXT_SEARCH); + if (txt_search) + IupSetFocus(txt_search); + return IUP_IGNORE; + } + return IUP_DEFAULT; +} diff --git a/src/ui/main_window.c b/src/ui/main_window.c index 3c1d52c..b7a2654 100644 --- a/src/ui/main_window.c +++ b/src/ui/main_window.c @@ -181,6 +181,7 @@ Ihandle *create_main_window(void) IupSetAttribute(dlg, "MINSIZE", lua_config_get_string("dialog", "minsize")); IupSetAttribute(dlg, "MINBOX", "NO"); IupSetAttribute(dlg, "MAXBOX", "NO"); + IupSetCallback(dlg, "K_ANY", (Icallback)dlg_k_any_cb); return dlg; }