diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-29 12:33:36 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-29 12:33:36 -0400 |
| commit | 07a877fa6e7144deb4b92e82de658c42d91c933a (patch) | |
| tree | b9190a486a6da9768280adca25ff5efdac210cdd /area_unix.go | |
| parent | 4dd7eebc315887c7f7b09e03b00c110823818e06 (diff) | |
Updated the GTK+ implementation and test programs to reflect the new KeyEvent setup.
Diffstat (limited to 'area_unix.go')
| -rw-r--r-- | area_unix.go | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/area_unix.go b/area_unix.go index b4a7600..14e91a4 100644 --- a/area_unix.go +++ b/area_unix.go @@ -180,27 +180,21 @@ func doKeyEvent(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer, up bool var ke KeyEvent e := (*C.GdkEventKey)(unsafe.Pointer(event)) -fmt.Println("$$", up, e.hardware_keycode) s := (*sysData)(unsafe.Pointer(data)) keyval := e.keyval if extkey, ok := extkeys[keyval]; ok { ke.ExtKey = extkey - } else if predef, ok := predefkeys[keyval]; ok { - ke.ASCII = predef +// } 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 - } else { - cp := C.gdk_keyval_to_unicode(keyval) - // GDK keycodes in GDK 3.4 the ASCII plane map to their ASCII values - // (proof: https://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h?h=gtk-3-4) - // this also handles the numeric keypad keys (proof: https://git.gnome.org/browse/gtk+/tree/gdk/gdkkeyuni.c?h=gtk-3-4#n846) - // the cp < 0x20 will also handle the case where the key is totally unknown to us (gdk_keyval_to_unicode() returns 0) and the space key - if cp < 0x20 || cp >= 0x7F { - // TODO really stop here? or should we handle modifiers? - return false // pretend unhandled - } - ke.ASCII = byte(cp) + } else if key, ok := scancodeMap[uintptr(e.hardware_keycode) - 8]; ok { + // see events_notdarwin.go for details of the above map lookup + ke.Key = key + } else { // no match + // TODO really stop here? [or should we handle modifiers?] + return false // pretend unhandled } state := translateModifiers(e.state, e.window) ke.Modifiers = makeModifiers(state, ke.Modifiers) |
