Work around what looks like a PalmOS bug that generates a spurious

keyDown event to a form put up while processing a keyUp event in the
main form: set a flag while handling key events, and drop the first
keyDown in child forms when it's set.
This commit is contained in:
ehouse 2007-01-27 15:10:10 +00:00
parent f56b170b2a
commit 9d74699181
2 changed files with 22 additions and 2 deletions

View file

@ -2179,6 +2179,9 @@ handleKeyEvent( PalmAppGlobals* globals, const EventType* event,
BoardCtxt* board = globals->game.board;
XP_S16 incr = 0; /* needed for tungsten and zodiac, but not treo since
the OS handled focus movement between objects. */
globals->handlingKeyEvent = XP_TRUE;
#ifdef DO_TUNGSTEN_FIVEWAY
if ( !globals->generatesKeyUp ) { /* this is the Tungsten case */
if ( event->data.keyDown.chr == vchrNavChange ) {
@ -2319,6 +2322,9 @@ handleKeyEvent( PalmAppGlobals* globals, const EventType* event,
}
LOG_RETURNF( "%d", draw );
*handledP = handled;
globals->handlingKeyEvent = XP_FALSE;
return draw;
} /* handleKeyEvent */
@ -2992,8 +2998,12 @@ handleScrollInAsk( EventPtr event )
break;
case keyDownEvent:
/* don't scroll a menu if open! */
if ( FrmGetWindowHandle( FrmGetActiveForm() ) == WinGetDrawWindow() ) {
if ( globals->ignoreFirstKeyDown ) {
globals->ignoreFirstKeyDown = XP_FALSE;
XP_ASSERT( result );
} else if ( FrmGetWindowHandle( FrmGetActiveForm() )
== WinGetDrawWindow() ) {
/* don't scroll a menu if open! */
switch ( event->data.keyDown.chr ) {
case pageUpChr:
case vchrRockerUp:
@ -3128,6 +3138,11 @@ palmask( PalmAppGlobals* globals, XP_UCHAR* str, XP_UCHAR* yesButton,
centerControl( form, XW_ASK_YES_BUTTON_ID );
}
/* This is making me puke.... :-) */
if ( globals->handlingKeyEvent ) {
globals->ignoreFirstKeyDown = XP_TRUE;
}
FrmSetEventHandler( form, handleScrollInAsk );
globals->prevScroll = 0;

View file

@ -298,6 +298,11 @@ struct PalmAppGlobals {
XP_Bool hasTreoFiveWay;
XP_Bool generatesKeyUp;
XP_Bool isZodiac;
/* PalmOS seems pretty broken w.r.t. key events. If I put up a modal
dialog while in the process of handling a keyUp, that form gets a
keyDown (and not with the repeat bit set either.) Hack around it. */
XP_Bool handlingKeyEvent;
XP_Bool ignoreFirstKeyDown;
XP_U16 lastKeyDown;