From 02f78d5eb03670bc07f615ad629e1ec03959be14 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 8 Oct 2015 07:30:10 +0200 Subject: Refactored EventHandler and friends. --- plugingui/nativewindow_win32.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'plugingui/nativewindow_win32.cc') diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc index 871bafe..fcee1a6 100644 --- a/plugingui/nativewindow_win32.cc +++ b/plugingui/nativewindow_win32.cc @@ -125,24 +125,28 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) if(msg == WM_LBUTTONUP || msg == WM_LBUTTONDBLCLK || - msg == WM_LBUTTONDOWN) e->button = 0; - - if(msg == WM_RBUTTONUP || + msg == WM_LBUTTONDOWN) e->button = ButtonEvent::Left; + else if(msg == WM_RBUTTONUP || msg == WM_RBUTTONDBLCLK || - msg == WM_RBUTTONDOWN) e->button = 1; - - if(msg == WM_MBUTTONUP || + msg == WM_RBUTTONDOWN) e->button = ButtonEvent::Middle; + else if(msg == WM_MBUTTONUP || msg == WM_MBUTTONDBLCLK || - msg == WM_MBUTTONDOWN) e->button = 2; + msg == WM_MBUTTONDOWN) e->button = ButtonEvent::Right; + else { + delete e; + break; // unknown button + } - e->direction = 0; if(msg == WM_LBUTTONUP || msg == WM_RBUTTONUP || - msg == WM_MBUTTONUP) e->direction = -1; - - if(msg == WM_LBUTTONDOWN || + msg == WM_MBUTTONUP) e->direction = ButtonEvent::Up; + else if(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || - msg == WM_MBUTTONDOWN) e->direction = 1; + msg == WM_MBUTTONDOWN) e->direction = ButtonEvent::Down; + else { + delete e; + break; // unknown direction + } e->doubleclick = (msg == WM_LBUTTONDBLCLK || msg == WM_RBUTTONDBLCLK || @@ -171,7 +175,7 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) default: e->keycode = GUI::KeyEvent::KEY_UNKNOWN; break; } e->text = ""; - e->direction = -1; + e->direction = KeyEvent::Up; native->event = e; } break; @@ -183,7 +187,7 @@ LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) GUI::KeyEvent *e = new GUI::KeyEvent(); e->keycode = GUI::KeyEvent::KEY_CHARACTER; e->text += (char)wp; - e->direction = -1; + e->direction = KeyEvent::Up; native->event = e; } } -- cgit v1.2.3