aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/window.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-23 23:08:54 +0800
committercrupest <crupest@outlook.com>2018-09-23 23:08:54 +0800
commitbe84ddd03d3b59c0c27aa538d5ef5129f94d511c (patch)
tree66448a2559b216352cca5ee28a470cbc8fb9c08a /CruUI/ui/window.cpp
parent800c98a732f82df09a98fddba91eddb5d675318d (diff)
downloadcru-be84ddd03d3b59c0c27aa538d5ef5129f94d511c.tar.gz
cru-be84ddd03d3b59c0c27aa538d5ef5129f94d511c.tar.bz2
cru-be84ddd03d3b59c0c27aa538d5ef5129f94d511c.zip
Add keyboard events to control.
Diffstat (limited to 'CruUI/ui/window.cpp')
-rw-r--r--CruUI/ui/window.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/CruUI/ui/window.cpp b/CruUI/ui/window.cpp
index 6ff962b6..34a54512 100644
--- a/CruUI/ui/window.cpp
+++ b/CruUI/ui/window.cpp
@@ -204,8 +204,7 @@ namespace cru
if (!native_message_event.IsNoHandler())
{
- const events::WindowNativeMessage message{hwnd, msg, w_param, l_param};
- events::WindowNativeMessageEventArgs args(this, this, message);
+ events::WindowNativeMessageEventArgs args(this, this, {hwnd, msg, w_param, l_param});
native_message_event.Raise(args);
if (args.GetResult().has_value())
{
@@ -293,6 +292,18 @@ namespace cru
result = 0;
return true;
}
+ case WM_KEYDOWN:
+ OnKeyDownInternal(static_cast<int>(w_param));
+ result = 0;
+ return true;
+ case WM_KEYUP:
+ OnKeyUpInternal(static_cast<int>(w_param));
+ result = 0;
+ return true;
+ case WM_CHAR:
+ OnCharInternal(static_cast<wchar_t>(w_param));
+ result = 0;
+ return true;
case WM_SIZE:
OnResizeInternal(LOWORD(l_param), HIWORD(l_param));
result = 0;
@@ -553,6 +564,21 @@ namespace cru
DispatchEvent(control, &Control::RaiseMouseUpEvent, nullptr, dip_point, button);
}
+ void Window::OnKeyDownInternal(int virtual_code)
+ {
+ DispatchEvent(focus_control_, &Control::RaiseKeyDownEvent, nullptr, virtual_code);
+ }
+
+ void Window::OnKeyUpInternal(int virtual_code)
+ {
+ DispatchEvent(focus_control_, &Control::RaiseKeyUpEvent, nullptr, virtual_code);
+ }
+
+ void Window::OnCharInternal(wchar_t c)
+ {
+ DispatchEvent(focus_control_, &Control::RaiseCharEvent, nullptr, c);
+ }
+
void Window::OnActivatedInternal()
{
events::UiEventArgs args(this, this);