From bafb13dd2fa4a8eb1de7c7772e912db13d59a86d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 29 Mar 2014 19:30:08 -0400 Subject: [PATCH] Added Alt+[key] and F10 handling to Windows Area key events. Also more TODOs. --- area_windows.go | 38 +++++++++++++++++++++++++++++--------- todo.md | 1 + 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/area_windows.go b/area_windows.go index 52cc781..c30f4a3 100644 --- a/area_windows.go +++ b/area_windows.go @@ -465,6 +465,15 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara _MA_ACTIVATE = 1 ) + defwndproc := func() _LRESULT { + r1, _, _ := defWindowProc.Call( + uintptr(hwnd), + uintptr(uMsg), + uintptr(wParam), + uintptr(lParam)) + return _LRESULT(r1) + } + switch uMsg { case _WM_PAINT: paintArea(s) @@ -479,22 +488,25 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara // TODO make this unnecessary if s != nil && s.hwnd != 0 { // this message can be sent before s is assigned properly scrollArea(s, wParam, _SB_VERT) + return 0 } - return 0 + return defwndproc() case _WM_SIZE: // TODO make this unnecessary if s != nil && s.hwnd != 0 { // this message can be sent before s is assigned properly adjustAreaScrollbars(s) + return 0 } - return 0 + return defwndproc() case _WM_MOUSEACTIVATE: // register our window for keyboard input // (see http://www.catch22.net/tuts/custom-controls) r1, _, err := _setFocus.Call(uintptr(s.hwnd)) if r1 == 0 { // failure panic(fmt.Errorf("error giving Area keyboard focus: %v", err)) + return _MA_ACTIVATE // TODO eat the click? } - return _MA_ACTIVATE // TODO eat the click? + return defwndproc() case _WM_MOUSEMOVE: areaMouseEvent(s, 0, false, 0, wParam, lParam) return 0 @@ -532,6 +544,19 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara case _WM_KEYUP: areaKeyEvent(s, true, wParam, lParam) return 0 + // Alt+[anything] and F10 send these instead + case _WM_SYSKEYDOWN: + handled := areaKeyEvent(s, false, wParam, lParam) + if handled { + return 0 + } + return defwndproc() + case _WM_SYSKEYUP: + handled := areaKeyEvent(s, true, wParam, lParam) + if handled { + return 0 + } + return defwndproc() case msgSetAreaSize: s.areawidth = int(wParam) // see setAreaSize() in sysdata_windows.go s.areaheight = int(lParam) @@ -539,12 +564,7 @@ func areaWndProc(s *sysData) func(hwnd _HWND, uMsg uint32, wParam _WPARAM, lPara repaintArea(s) // this calls for an update return 0 default: - r1, _, _ := defWindowProc.Call( - uintptr(hwnd), - uintptr(uMsg), - uintptr(wParam), - uintptr(lParam)) - return _LRESULT(r1) + return defwndproc() } panic(fmt.Sprintf("areaWndProc message %d did not return: internal bug in ui library", uMsg)) } diff --git a/todo.md b/todo.md index 46c34db..1181412 100644 --- a/todo.md +++ b/todo.md @@ -87,6 +87,7 @@ super ultra important things: - references: https://github.com/glfw/glfw/blob/master/src/win32_window.c#L182, http://www.catch22.net/tuts/custom-controls - Area redraw on Windows is still a bit flaky, especially after changing the Area size to something larger than the window size and then resizing the window(???) - despite us explicitly clearing the clip area on Windows, Area still doesn't seem to draw alpha bits correctly... it appears as if we are drawing over the existing image each time +- on Windows, Shift+(num pad key) triggers the shifted key code when num lock is off; will need to reorder key code tests on all platforms to fix this important things: - make specific wording in documentation consistent (make/create, etc.)