aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-16 01:41:33 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-16 01:41:33 +0200
commitc451880d807cb07986cb3553e4424219166ced5e (patch)
tree7df0771ba7278a4156f991e61c3e2ad7c456f5d3
parent9915fb625edc552c804224d2a425aec271455668 (diff)
downloaduGFX-c451880d807cb07986cb3553e4424219166ced5e.tar.gz
uGFX-c451880d807cb07986cb3553e4424219166ced5e.tar.bz2
uGFX-c451880d807cb07986cb3553e4424219166ced5e.zip
Adding keyboard event handler to checkbox widget
-rw-r--r--src/gwin/gwin_checkbox.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gwin/gwin_checkbox.c b/src/gwin/gwin_checkbox.c
index 83d5bc38..6401092d 100644
--- a/src/gwin/gwin_checkbox.c
+++ b/src/gwin/gwin_checkbox.c
@@ -55,6 +55,23 @@ static void SendCheckboxEvent(GWidgetObject *gw) {
}
#endif
+#if GINPUT_NEED_KEYBOARD
+ static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke)
+ {
+ // Only react on KEYDOWN events. Ignore KEYUP events.
+ if (pke->keystate & GKEYSTATE_KEYUP) {
+ break;
+ }
+
+ // ENTER and SPACE keys to check/uncheck the checkbox
+ if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
+ gw->g.flags ^= GCHECKBOX_FLG_CHECKED;
+ }
+
+ _gwinUpdate((GHandle)gw);
+ }
+#endif
+
#if GINPUT_NEED_TOGGLE
static void CheckboxToggleOn(GWidgetObject *gw, uint16_t role) {
(void) role;
@@ -93,7 +110,7 @@ static const gwidgetVMT checkboxVMT = {
#endif
#if GINPUT_NEED_KEYBOARD
{
- 0 // Process keyboard events
+ _keyboardEvent // Process keyboard events
},
#endif
#if GINPUT_NEED_TOGGLE