From 63c5e4949f63470bd20d2bc35a9fcc0b50795910 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 16 Aug 2015 01:35:46 +0200 Subject: [PATCH] Adding KEYUP events --- src/gwin/gwin_textedit.c | 5 +++++ src/gwin/gwin_widget.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c index 8d242ec7..99708a0a 100644 --- a/src/gwin/gwin_textedit.c +++ b/src/gwin/gwin_textedit.c @@ -67,6 +67,11 @@ static void _shiftTextRight(char* buffer, size_t bufferSize, size_t index, char #if GINPUT_NEED_KEYBOARD static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke) { + // Only react on KEYDOWN events. Ignore KEYUP events. + if (pke->keystate & GKEYSTATE_KEYUP) { + return; + } + // Is it a special key? if (pke->keystate & GKEYSTATE_SPECIAL) { // Arrow keys to move the cursor diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c index f135b306..84168b09 100644 --- a/src/gwin/gwin_widget.c +++ b/src/gwin/gwin_widget.c @@ -151,6 +151,11 @@ static void gwidgetEvent(void *param, GEvent *pe) { // If Tab key pressed then set focus to next widget if (pke->bytecount == 1 && pke->c[0] == GKEY_TAB) { + // Only react on KEYDOWN events. Ignore KEYUP events. + if (pke->keystate & GKEYSTATE_KEYUP) { + break; + } + // Get the next widget bool_t foundWidget = FALSE; bool_t endOfListDetected = FALSE; @@ -323,7 +328,7 @@ void _gwidgetInit(void) geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES); #if GINPUT_NEED_KEYBOARD - geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), 0); + geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), GLISTEN_KEYUP); #endif }