diff --git a/xwords4/palm/palmmain.c b/xwords4/palm/palmmain.c index 111d63386..ae15f2885 100644 --- a/xwords4/palm/palmmain.c +++ b/xwords4/palm/palmmain.c @@ -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; diff --git a/xwords4/palm/palmmain.h b/xwords4/palm/palmmain.h index d866fe426..e3e65617b 100644 --- a/xwords4/palm/palmmain.h +++ b/xwords4/palm/palmmain.h @@ -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;