From 75acdfd9adb1f62411c17e32949dbd24aa98833f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 29 Mar 2014 13:01:42 -0400 Subject: [PATCH] Re-added the numeric keypad keys to ExtKey and removed predefkeys in area_unix.go since all are now being handled. --- area.go | 8 ++++---- area_unix.go | 20 +++++--------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/area.go b/area.go index 3a6b604..05d3361 100644 --- a/area.go +++ b/area.go @@ -194,7 +194,7 @@ const ( F10 F11 F12 -/* N0 // numpad keys; independent of Num Lock state + N0 // numpad keys; independent of Num Lock state N1 // N0..N9 are guaranteed to be consecutive N2 N3 @@ -210,7 +210,7 @@ const ( NSubtract NMultiply NDivide -*/ _nextkeys // for sanity check + _nextkeys // for sanity check ) // EffectiveKey returns e.Key if it is set. @@ -222,7 +222,7 @@ func (e KeyEvent) EffectiveKey() byte { if e.Key != 0 { return e.Key } -/* k := e.ExtKey + k := e.ExtKey switch { case k >= N0 && k <= N9: return byte(k - N0) + '0' @@ -239,7 +239,7 @@ func (e KeyEvent) EffectiveKey() byte { case k == NDivide: return '/' } -*/ return 0 + return 0 } // Modifiers indicates modifier keys being held during an event. diff --git a/area_unix.go b/area_unix.go index f20b467..9e1370d 100644 --- a/area_unix.go +++ b/area_unix.go @@ -184,8 +184,6 @@ func doKeyEvent(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer, up bool keyval := e.keyval if extkey, ok := extkeys[keyval]; ok { ke.ExtKey = extkey -// } else if predef, ok := predefkeys[keyval]; ok { -// ke.ASCII = predef } else if mod, ok := modonlykeys[keyval]; ok { // modifier keys don't seem to be set on their initial keypress; set them here ke.Modifiers |= mod @@ -283,6 +281,8 @@ var extkeys = map[C.guint]ExtKey{ C.GDK_KEY_F10: F10, C.GDK_KEY_F11: F11, C.GDK_KEY_F12: F12, + // numpad numeric keys are handled in events_notdarwin.go + C.GDK_KEY_KP_Enter: NEnter, } // sanity check @@ -292,25 +292,15 @@ func init() { included[v] = true } for i := 1; i < int(_nextkeys); i++ { + if i >= int(_N0) && i <= int(_N9) { // skip numpad numbers + continue + } if !included[i] { panic(fmt.Errorf("error: not all ExtKeys defined on Unix (missing %d)", i)) } } } -var predefkeys = map[C.guint]byte{ - C.GDK_KEY_Return: '\n', - // TODO C.GDK_KEY_Linefeed too? What key is this? - C.GDK_KEY_Tab: '\t', - C.GDK_KEY_BackSpace: '\b', - // tests indicate that this is sent on Shift+Tab - C.GDK_KEY_ISO_Left_Tab: '\t', - // numeric keypad equivalents: - C.GDK_KEY_KP_Enter: '\n', - // all other numeric keypad equivalents are handled by gdk_keymap_to_unicode() as mentioned above - // no space; handled by the code above -} - var modonlykeys = map[C.guint]Modifiers{ C.GDK_KEY_Shift_L: Shift, C.GDK_KEY_Shift_R: Shift,