UI KeyEvent previous state and repeat count

This commit is contained in:
Dr. Chat 2015-08-18 18:45:35 -05:00
parent a668556d7f
commit 38064acd51
2 changed files with 13 additions and 3 deletions

View File

@ -28,8 +28,11 @@ class UIEvent {
class KeyEvent : public UIEvent {
public:
KeyEvent(Window* target, int key_code)
: UIEvent(target), key_code_(key_code) {}
KeyEvent(Window* target, int key_code, int repeat_count, bool prev_state)
: UIEvent(target),
key_code_(key_code),
repeat_count_(repeat_count),
prev_state_(prev_state) {}
~KeyEvent() override = default;
bool is_handled() const { return handled_; }
@ -37,9 +40,15 @@ class KeyEvent : public UIEvent {
int key_code() const { return key_code_; }
int repeat_count() const { return repeat_count_; }
bool prev_state() const { return prev_state_; }
private:
bool handled_ = false;
int key_code_ = 0;
int repeat_count_ = 0;
bool prev_state_ = false; // Key previously down(true) or up(false)
};
class MouseEvent : public UIEvent {

View File

@ -503,7 +503,8 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) {
}
bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) {
auto e = KeyEvent(this, static_cast<int>(wParam));
auto e = KeyEvent(this, static_cast<int>(wParam), lParam & 0xFFFF,
!!(lParam & 0x00000002));
switch (message) {
case WM_KEYDOWN:
OnKeyDown(&e);