Fix keyboard handling for gwin checkbox and button
This commit is contained in:
parent
ea0419c29b
commit
8603afd309
@ -53,15 +53,15 @@
|
|||||||
// ENTER and SPACE keys to press the button
|
// ENTER and SPACE keys to press the button
|
||||||
if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
|
if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
|
||||||
|
|
||||||
// Press or release event?
|
// Some keyboards (eg the virtual keyboard) can't send keyup events.
|
||||||
if (pke->keystate & GKEYSTATE_KEYUP) {
|
// Even for those that do we may not be listening for them.
|
||||||
gw->g.flags &= ~GBUTTON_FLG_PRESSED;
|
// We should really process on a keydown and then set a timer to display
|
||||||
} else {
|
// the button release but that requires an extra timer and lots of
|
||||||
gw->g.flags |= GBUTTON_FLG_PRESSED;
|
// complication. Instead we cheat by not providing user feedback of the keypress.
|
||||||
}
|
if (!(pke->keystate & GKEYSTATE_KEYUP))
|
||||||
|
_gwinSendEvent(&gw->g, GEVENT_GWIN_BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gwinUpdate((GHandle)gw);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,16 +56,15 @@ static void SendCheckboxEvent(GWidgetObject *gw) {
|
|||||||
static void CheckboxKeyboard(GWidgetObject* gw, GEventKeyboard* pke)
|
static void CheckboxKeyboard(GWidgetObject* gw, GEventKeyboard* pke)
|
||||||
{
|
{
|
||||||
// Only react on KEYDOWN events. Ignore KEYUP events.
|
// Only react on KEYDOWN events. Ignore KEYUP events.
|
||||||
if (pke->keystate & GKEYSTATE_KEYUP) {
|
if ((pke->keystate & GKEYSTATE_KEYUP))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// ENTER and SPACE keys to check/uncheck the checkbox
|
// ENTER and SPACE keys to check/uncheck the checkbox
|
||||||
if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
|
if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
|
||||||
gw->g.flags ^= GCHECKBOX_FLG_CHECKED;
|
gw->g.flags ^= GCHECKBOX_FLG_CHECKED;
|
||||||
|
_gwinUpdate((GHandle)gw);
|
||||||
|
SendCheckboxEvent(gw);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gwinUpdate((GHandle)gw);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user