mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 02:09:46 +08:00
feat(shortcuts): 添加全局快捷键 Ctrl+N/S/F
- Ctrl+N: 新建路径 - Ctrl+S: 保存(确定) - Ctrl+F: 聚焦搜索框 - 对话框级 K_ANY 回调,列表级 K_ANY 保持 Ctrl+Z/Y/DEL Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user