diff options
author | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-16 01:36:33 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@seriouslyembedded.com> | 2015-08-16 01:36:33 +0200 |
commit | 9915fb625edc552c804224d2a425aec271455668 (patch) | |
tree | e514df014f85e89b4df1ad3c7c96cc5073cc26e2 /src/gwin/gwin_button.c | |
parent | 63c5e4949f63470bd20d2bc35a9fcc0b50795910 (diff) | |
download | uGFX-9915fb625edc552c804224d2a425aec271455668.tar.gz uGFX-9915fb625edc552c804224d2a425aec271455668.tar.bz2 uGFX-9915fb625edc552c804224d2a425aec271455668.zip |
Adding keyboard event handler to button widget
Diffstat (limited to 'src/gwin/gwin_button.c')
-rw-r--r-- | src/gwin/gwin_button.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/gwin/gwin_button.c b/src/gwin/gwin_button.c index 8a178b72..854f540b 100644 --- a/src/gwin/gwin_button.c +++ b/src/gwin/gwin_button.c @@ -50,6 +50,24 @@ } #endif +#if GINPUT_NEED_KEYBOARD + static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke) + { + // ENTER and SPACE keys to press the button + if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) { + + // Press or release event? + if (pke->keystate & GKEYSTATE_KEYUP) { + gw->g.flags &= ~GBUTTON_FLG_PRESSED; + } else { + gw->g.flags |= GBUTTON_FLG_PRESSED; + } + } + + _gwinUpdate((GHandle)gw); + } +#endif + #if GINPUT_NEED_TOGGLE // A toggle off has occurred static void ButtonToggleOff(GWidgetObject *gw, uint16_t role) { @@ -97,7 +115,7 @@ static const gwidgetVMT buttonVMT = { #endif #if GINPUT_NEED_KEYBOARD { - 0 // Process keyboard events + _keyboardEvent // Process keyboard events }, #endif #if GINPUT_NEED_TOGGLE |