Adding keyboard event handler to button widget

ugfx_release_2.6
Joel Bodenmann 2015-08-16 01:36:33 +02:00
parent 63c5e4949f
commit 9915fb625e
1 changed files with 19 additions and 1 deletions

View File

@ -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