From 055cd36b20d9ab9d002e867bf31f0a64782c3789 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 29 May 2014 12:17:02 -0400 Subject: [PATCH] Added the new Modifiers handling to the Windows backend. --- area_windows.go | 20 ++++++++++++++++++++ zconstants_windows_386.go | 6 ++++++ zconstants_windows_amd64.go | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/area_windows.go b/area_windows.go index 5664ffa..6269002 100644 --- a/area_windows.go +++ b/area_windows.go @@ -513,6 +513,10 @@ func areaKeyEvent(s *sysData, up bool, wparam _WPARAM, lparam _LPARAM) bool { ke.ExtKey = NEnter } else if extkey, ok := extkeys[wparam]; ok { ke.ExtKey = extkey + } else if mod, ok := modonlykeys[wparam]; ok { + ke.Modifier = mod + // don't include the modifier in ke.Modifiers + ke.Modifiers &^= mod } else if xke, ok := fromScancode(uintptr(scancode)); ok { // one of these will be nonzero ke.Key = xke.Key @@ -580,6 +584,22 @@ func init() { } } +var modonlykeys = map[_WPARAM]Modifiers{ + // TODO except for Super, are the separate left/right necessary? + _VK_CONTROL: Ctrl, + _VK_LCONTROL: Ctrl, + _VK_RCONTROL: Ctrl, + _VK_MENU: Alt, + _VK_LMENU: Alt, + _VK_RMENU: Alt, + _VK_SHIFT: Shift, + _VK_LSHIFT: Shift, + _VK_RSHIFT: Shift, + // there's no combined Windows key virtual-key code as there is with the others + _VK_LWIN: Super, + _VK_RWIN: Super, +} + var ( _setFocus = user32.NewProc("SetFocus") ) diff --git a/zconstants_windows_386.go b/zconstants_windows_386.go index 4c63c62..4427631 100644 --- a/zconstants_windows_386.go +++ b/zconstants_windows_386.go @@ -105,14 +105,20 @@ const _VK_F8 = 119 const _VK_F9 = 120 const _VK_HOME = 36 const _VK_INSERT = 45 +const _VK_LCONTROL = 162 const _VK_LEFT = 37 +const _VK_LMENU = 164 +const _VK_LSHIFT = 160 const _VK_LWIN = 91 const _VK_MENU = 18 const _VK_MULTIPLY = 106 const _VK_NEXT = 34 const _VK_PRIOR = 33 +const _VK_RCONTROL = 163 const _VK_RETURN = 13 const _VK_RIGHT = 39 +const _VK_RMENU = 165 +const _VK_RSHIFT = 161 const _VK_RWIN = 92 const _VK_SHIFT = 16 const _VK_SUBTRACT = 109 diff --git a/zconstants_windows_amd64.go b/zconstants_windows_amd64.go index f1b0060..0274d3a 100644 --- a/zconstants_windows_amd64.go +++ b/zconstants_windows_amd64.go @@ -105,14 +105,20 @@ const _VK_F8 = 119 const _VK_F9 = 120 const _VK_HOME = 36 const _VK_INSERT = 45 +const _VK_LCONTROL = 162 const _VK_LEFT = 37 +const _VK_LMENU = 164 +const _VK_LSHIFT = 160 const _VK_LWIN = 91 const _VK_MENU = 18 const _VK_MULTIPLY = 106 const _VK_NEXT = 34 const _VK_PRIOR = 33 +const _VK_RCONTROL = 163 const _VK_RETURN = 13 const _VK_RIGHT = 39 +const _VK_RMENU = 165 +const _VK_RSHIFT = 161 const _VK_RWIN = 92 const _VK_SHIFT = 16 const _VK_SUBTRACT = 109