diff --git a/include/LCUI/main.h b/include/LCUI/main.h index 6192558a..d0fd4136 100644 --- a/include/LCUI/main.h +++ b/include/LCUI/main.h @@ -68,8 +68,16 @@ typedef struct LCUI_PaintEvent_ { LCUI_Rect rect; } LCUI_PaintEvent; +/** The event structure to describe a user interaction with the keyboard */ typedef struct LCUI_KeyboardEvent_ { + /** The virtual-key code of the nonsystem key */ int code; + + /** whether the Ctrl key was active when the key event was generated */ + LCUI_BOOL ctrl_key; + + /** whether the Shift key was active when the key event was generated */ + LCUI_BOOL shift_key; } LCUI_KeyboardEvent; typedef struct LCUI_MouseMotionEvent_ { diff --git a/src/platform/linux/linux_x11keyboard.c b/src/platform/linux/linux_x11keyboard.c index 7b2079a9..3bd2d7b9 100644 --- a/src/platform/linux/linux_x11keyboard.c +++ b/src/platform/linux/linux_x11keyboard.c @@ -135,6 +135,8 @@ static void OnKeyboardMessage(LCUI_Event ev, void *arg) _DEBUG_MSG("keycode: %d, keyscancode: %u, keysym: %lu\n", keysym, x_ev->xkey.keycode, keysym); sys_ev.key.code = ConvertKeyCode(keysym); + sys_ev.key.shift_key = x_ev->xkey.state & ShiftMask ? TRUE : FALSE; + sys_ev.key.ctrl_key = x_ev->xkey.state & ControlMask ? TRUE : FALSE; _DEBUG_MSG("shift: %d, ctrl: %d\n", sys_ev.key.shift_key, sys_ev.key.ctrl_key); LCUI_TriggerEvent(&sys_ev, NULL); diff --git a/src/platform/windows/uwp_input.cpp b/src/platform/windows/uwp_input.cpp index 4fe5628f..16b3906b 100644 --- a/src/platform/windows/uwp_input.cpp +++ b/src/platform/windows/uwp_input.cpp @@ -35,10 +35,10 @@ #include using namespace LCUICore; +using namespace Windows::UI; using namespace Windows::UI::Core; using namespace Windows::UI::Input; using namespace Windows::Devices::Input; -using namespace Windows::UI; using namespace Windows::Foundation; using namespace Windows::System; @@ -253,6 +253,8 @@ void InputDriver::OnKeyDown(CoreWindow^ sender, KeyEventArgs^ args) { LCUI_SysEventRec ev; ev.type = LCUI_KEYDOWN; + ev.key.ctrl_key = FALSE; + ev.key.shift_key = FALSE; ev.key.code = static_cast(args->VirtualKey); LCUI_TriggerEvent(&ev, NULL); LCUI_DestroyEvent(&ev); @@ -262,6 +264,8 @@ void InputDriver::OnKeyUp(CoreWindow^ sender, KeyEventArgs^ args) { LCUI_SysEventRec ev; ev.type = LCUI_KEYUP; + ev.key.ctrl_key = FALSE; + ev.key.shift_key = FALSE; ev.key.code = static_cast(args->VirtualKey); LCUI_TriggerEvent(&ev, NULL); LCUI_DestroyEvent(&ev); diff --git a/src/platform/windows/uwp_renderer.cpp b/src/platform/windows/uwp_renderer.cpp index aa2b3cca..5bfb2d6e 100644 --- a/src/platform/windows/uwp_renderer.cpp +++ b/src/platform/windows/uwp_renderer.cpp @@ -274,7 +274,7 @@ LCUI_DisplayDriver LCUI_CreateUWPDisplay(void) driver->endPaint = UWPSurface_EndPaint; driver->bindEvent = UWPDisplay_BindEvent; Graph_Init(&display.frame); - display.frame.color_type = COLOR_TYPE_ARGB; + display.frame.color_type = LCUI_COLOR_TYPE_ARGB; display.surface = NULL; display.trigger = EventTrigger(); display.is_inited = TRUE; diff --git a/src/platform/windows/windows_ime.c b/src/platform/windows/windows_ime.c index e10aac99..12dc4db5 100644 --- a/src/platform/windows/windows_ime.c +++ b/src/platform/windows/windows_ime.c @@ -60,17 +60,12 @@ static void WinIME_OnChar(LCUI_Event e, void *arg) LCUIIME_Commit(text, 2); } -/** -* 输入法被打开时的处理 -* 可以在输入法被打开时,初始化相关数据,链接至词库什么的 -**/ static LCUI_BOOL IME_Open(void) { LCUI_BindSysEvent(WM_CHAR, WinIME_OnChar, NULL, NULL); return TRUE; } -/** 输入法被关闭时的处理 */ static LCUI_BOOL IME_Close(void) { LCUI_UnbindSysEvent(WM_CHAR, WinIME_OnChar); diff --git a/src/platform/windows/windows_keyboard.c b/src/platform/windows/windows_keyboard.c index 740c7e8c..f04598f0 100644 --- a/src/platform/windows/windows_keyboard.c +++ b/src/platform/windows/windows_keyboard.c @@ -38,19 +38,20 @@ static void OnKeyboardMessage(LCUI_Event ev, void *arg) { MSG* msg = arg; - static POINT mouse_pos; LCUI_SysEventRec sys_ev; + switch (msg->message) { case WM_KEYDOWN: sys_ev.type = LCUI_KEYDOWN; - sys_ev.key.code = msg->wParam; break; case WM_KEYUP: sys_ev.type = LCUI_KEYUP; - sys_ev.key.code = msg->wParam; break; default: return; } + sys_ev.key.code = msg->wParam; + sys_ev.key.shift_key = (GetKeyState(VK_SHIFT) & 0x8000) ? TRUE : FALSE; + sys_ev.key.ctrl_key = (GetKeyState(VK_CONTROL) & 0x8000) ? TRUE : FALSE; LCUI_TriggerEvent(&sys_ev, NULL); }