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; }