UI KeyEvent previous state and repeat count
This commit is contained in:
parent
a668556d7f
commit
38064acd51
|
@ -28,8 +28,11 @@ class UIEvent {
|
||||||
|
|
||||||
class KeyEvent : public UIEvent {
|
class KeyEvent : public UIEvent {
|
||||||
public:
|
public:
|
||||||
KeyEvent(Window* target, int key_code)
|
KeyEvent(Window* target, int key_code, int repeat_count, bool prev_state)
|
||||||
: UIEvent(target), key_code_(key_code) {}
|
: UIEvent(target),
|
||||||
|
key_code_(key_code),
|
||||||
|
repeat_count_(repeat_count),
|
||||||
|
prev_state_(prev_state) {}
|
||||||
~KeyEvent() override = default;
|
~KeyEvent() override = default;
|
||||||
|
|
||||||
bool is_handled() const { return handled_; }
|
bool is_handled() const { return handled_; }
|
||||||
|
@ -37,9 +40,15 @@ class KeyEvent : public UIEvent {
|
||||||
|
|
||||||
int key_code() const { return key_code_; }
|
int key_code() const { return key_code_; }
|
||||||
|
|
||||||
|
int repeat_count() const { return repeat_count_; }
|
||||||
|
bool prev_state() const { return prev_state_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handled_ = false;
|
bool handled_ = false;
|
||||||
int key_code_ = 0;
|
int key_code_ = 0;
|
||||||
|
|
||||||
|
int repeat_count_ = 0;
|
||||||
|
bool prev_state_ = false; // Key previously down(true) or up(false)
|
||||||
};
|
};
|
||||||
|
|
||||||
class MouseEvent : public UIEvent {
|
class MouseEvent : public UIEvent {
|
||||||
|
|
|
@ -503,7 +503,8 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Win32Window::HandleKeyboard(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) {
|
switch (message) {
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
OnKeyDown(&e);
|
OnKeyDown(&e);
|
||||||
|
|
Loading…
Reference in New Issue