add fnav resource for password dialog, and use it if device has fiveway.

Otherwise use FrmSetFocus.  This works around a bug where key event that
leaks through from parent dialog dismisses dialog (whereupon another comes
up, and eventually cursor is left flashing on parent.)
This commit is contained in:
ehouse 2007-06-18 13:21:36 +00:00
parent eeafb5c4f2
commit ab6ed444bb
4 changed files with 44 additions and 32 deletions

View file

@ -187,6 +187,14 @@ NAVIGATIONMAP
XW_MAIN_TRADE_BUTTON_ID XW_MAIN_TRADE_BUTTON_ID
XW_MAIN_DONE_BUTTON_ID XW_MAIN_DONE_BUTTON_ID
END END
NAVIGATION ID XW_PASSWORD_DIALOG_ID
INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState
INITIALOBJECTID XW_PASSWORD_PASS_FIELD
NAVIGATIONMAP
ROW XW_PASSWORD_PASS_FIELD
ROW XW_PASSWORD_OK_BUTTON XW_PASSWORD_CANCEL_BUTTON
END
#endif #endif
STRING ID 1000 "/palm/programs/Crosswords/" STRING ID 1000 "/palm/programs/Crosswords/"

View file

@ -429,7 +429,7 @@ handlePasswordTrigger( PalmAppGlobals* globals, UInt16 controlID )
name = (XP_UCHAR*)FldGetTextPtr( nameField ); name = (XP_UCHAR*)FldGetTextPtr( nameField );
len = sizeof(state->passwds[playerNum]); len = sizeof(state->passwds[playerNum]);
if ( askPassword( name, true, state->passwds[playerNum], &len )) { if ( askPassword( globals, name, true, state->passwds[playerNum], &len )) {
showMaskedPwd( controlID, len > 0 ); showMaskedPwd( controlID, len > 0 );
} }
} /* handlePasswordTrigger */ } /* handlePasswordTrigger */

View file

@ -145,7 +145,7 @@ static XP_Bool palm_util_getTraySearchLimits( XW_UtilCtxt* uc, XP_U16* min,
XP_U16* max ); XP_U16* max );
#endif #endif
static void userErrorFromStrId( PalmAppGlobals* globals, XP_U16 strID ); static void userErrorFromStrId( PalmAppGlobals* globals, XP_U16 strID );
static Boolean askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, static XP_Bool askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream,
XP_S16 titleID, Boolean closeAndDestroy ); XP_S16 titleID, Boolean closeAndDestroy );
static void displayFinalScores( PalmAppGlobals* globals ); static void displayFinalScores( PalmAppGlobals* globals );
static void updateScrollbar( PalmAppGlobals* globals, Int16 newValue ); static void updateScrollbar( PalmAppGlobals* globals, Int16 newValue );
@ -2025,7 +2025,7 @@ askOnClose( XWStreamCtxt* stream, void* closure )
{ {
PalmAppGlobals* globals = (PalmAppGlobals*)closure; PalmAppGlobals* globals = (PalmAppGlobals*)closure;
askFromStream( globals, stream, -1, false ); (void)askFromStream( globals, stream, -1, false );
} /* askOnClose */ } /* askOnClose */
#endif #endif
@ -2655,7 +2655,7 @@ mainViewHandleEvent( EventPtr event )
server_formatDictCounts( globals->game.server, stream, server_formatDictCounts( globals->game.server, stream,
4 ); /* 4: ncols */ 4 ); /* 4: ncols */
askFromStream( globals, stream, STR_VALUES_TITLE, true ); (void)askFromStream( globals, stream, STR_VALUES_TITLE, true );
} }
break; break;
@ -2663,7 +2663,7 @@ mainViewHandleEvent( EventPtr event )
if ( !!globals->game.board ) { if ( !!globals->game.board ) {
stream = makeSimpleStream( globals, NULL ); stream = makeSimpleStream( globals, NULL );
board_formatRemainingTiles( globals->game.board, stream ); board_formatRemainingTiles( globals->game.board, stream );
askFromStream( globals, stream, STR_REMAINS_TITLE, true ); (void)askFromStream( globals, stream, STR_REMAINS_TITLE, true );
} }
break; break;
@ -2675,8 +2675,8 @@ mainViewHandleEvent( EventPtr event )
model_writeGameHistory( globals->game.model, stream, model_writeGameHistory( globals->game.model, stream,
globals->game.server, gameOver ); globals->game.server, gameOver );
if ( stream_getSize( stream ) > 0 ) { if ( stream_getSize( stream ) > 0 ) {
askFromStream( globals, stream, STR_HISTORY_TITLE, (void)askFromStream( globals, stream, STR_HISTORY_TITLE,
XP_FALSE ); XP_FALSE );
} else { } else {
beep(); beep();
} }
@ -2988,7 +2988,7 @@ displayFinalScores( PalmAppGlobals* globals )
server_writeFinalScores( globals->game.server, stream ); server_writeFinalScores( globals->game.server, stream );
stream_putU8( stream, '\0' ); stream_putU8( stream, '\0' );
askFromStream( globals, stream, STR_FINAL_SCORES_TITLE, true ); (void)askFromStream( globals, stream, STR_FINAL_SCORES_TITLE, true );
} /* displayFinalScores */ } /* displayFinalScores */
XP_S16 XP_S16
@ -3220,7 +3220,7 @@ moveLeftOf( UInt16 rightID, UInt16 leftID )
} /* moveLeftOf */ } /* moveLeftOf */
Boolean XP_Bool
palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, XP_S16 titleID ) palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, XP_S16 titleID )
{ {
const XP_UCHAR* message; const XP_UCHAR* message;
@ -3231,9 +3231,9 @@ palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, XP_S16 titleID )
return palmask( globals, message, yes, titleID ); return palmask( globals, message, yes, titleID );
} /* palmaskFromStrId */ } /* palmaskFromStrId */
Boolean XP_Bool
palmask( PalmAppGlobals* globals, const XP_UCHAR* str, const XP_UCHAR* yesButton, palmask( PalmAppGlobals* globals, const XP_UCHAR* str,
XP_S16 titleID ) const XP_UCHAR* yesButton, XP_S16 titleID )
{ {
FormPtr form, prevForm; FormPtr form, prevForm;
FieldPtr field; FieldPtr field;
@ -3305,12 +3305,12 @@ palmask( PalmAppGlobals* globals, const XP_UCHAR* str, const XP_UCHAR* yesButton
return buttonHit == XW_ASK_YES_BUTTON_ID; return buttonHit == XW_ASK_YES_BUTTON_ID;
} /* palmask */ } /* palmask */
static Boolean static XP_Bool
askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, XP_S16 titleID, askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, XP_S16 titleID,
Boolean closeAndDestroy ) Boolean closeAndDestroy )
{ {
XP_U16 nBytes = stream_getSize( stream ); XP_U16 nBytes = stream_getSize( stream );
Boolean result; XP_Bool result;
XP_UCHAR* buffer; XP_UCHAR* buffer;
XP_ASSERT( nBytes < maxFieldTextLen ); XP_ASSERT( nBytes < maxFieldTextLen );
@ -3335,11 +3335,11 @@ askFromStream( PalmAppGlobals* globals, XWStreamCtxt* stream, XP_S16 titleID,
return result; return result;
} /* askFromStream */ } /* askFromStream */
Boolean XP_Bool
askPassword( const XP_UCHAR* name, Boolean isNew, XP_UCHAR* retbuf, askPassword( PalmAppGlobals* globals, const XP_UCHAR* name, XP_Bool isNew,
XP_U16* len ) XP_UCHAR* retbuf, XP_U16* len )
{ {
Boolean result = false; XP_Bool result = XP_FALSE;
FormPtr prevForm, form; FormPtr prevForm, form;
FieldPtr field; FieldPtr field;
UInt16 showMe; UInt16 showMe;
@ -3362,16 +3362,19 @@ askPassword( const XP_UCHAR* name, Boolean isNew, XP_UCHAR* retbuf,
FldSetTextPtr( field, (char*)name ); FldSetTextPtr( field, (char*)name );
FldDrawField( field ); FldDrawField( field );
} }
#ifdef XWFEATURE_FIVEWAY
setFormFocus( form, XW_PASSWORD_PASS_FIELD ); if ( !globals->hasTreoFiveWay ) {
#endif FrmSetFocus( form, FrmGetObjectIndex( form, XW_PASSWORD_PASS_FIELD ) );
field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD ); }
if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) { if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) {
char* enteredPass = FldGetTextPtr( field ); char* enteredPass;
XP_U16 enteredLen = !enteredPass? 0: StrLen(enteredPass); XP_U16 enteredLen;
field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD );
enteredPass = FldGetTextPtr( field );
enteredLen = enteredPass? StrLen(enteredPass) : 0;
if ( enteredLen < *len ) { if ( enteredLen < *len ) {
result = true; result = XP_TRUE;
if ( enteredLen > 0 ) { if ( enteredLen > 0 ) {
XP_MEMCPY( retbuf, enteredPass, enteredLen ); XP_MEMCPY( retbuf, enteredPass, enteredLen );
} }
@ -3684,10 +3687,11 @@ palm_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi,
} /* palm_util_userPickTile */ } /* palm_util_userPickTile */
static XP_Bool static XP_Bool
palm_util_askPassword( XW_UtilCtxt* XP_UNUSED(uc), const XP_UCHAR* name, XP_UCHAR* buf, palm_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
XP_U16* len ) XP_UCHAR* buf, XP_U16* len )
{ {
return askPassword( name, false, buf, len ); PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure;
return askPassword( globals, name, false, buf, len );
} /* palm_util_askPassword */ } /* palm_util_askPassword */
static void static void

View file

@ -412,9 +412,9 @@ void palm_drawctxt_destroy( DrawCtx* dctx );
void palm_warnf( char* format, ... ); void palm_warnf( char* format, ... );
Boolean askPassword( const XP_UCHAR* name, Boolean isNew, XP_UCHAR* retbuf, XP_Bool askPassword( PalmAppGlobals* globals, const XP_UCHAR* name,
XP_U16* len ); XP_Bool isNew, XP_UCHAR* retbuf, XP_U16* len );
Boolean palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId, XP_Bool palmaskFromStrId( PalmAppGlobals* globals, XP_U16 strId,
XP_S16 titleID ); XP_S16 titleID );
void freeSavedGamesData( MPFORMAL SavedGamesState* state ); void freeSavedGamesData( MPFORMAL SavedGamesState* state );
@ -422,7 +422,7 @@ void writeNameToGameRecord( PalmAppGlobals* globals, XP_S16 index,
char* newName, XP_U16 len ); char* newName, XP_U16 len );
const XP_UCHAR* getResString( PalmAppGlobals* globals, XP_U16 strID ); const XP_UCHAR* getResString( PalmAppGlobals* globals, XP_U16 strID );
Boolean palmask( PalmAppGlobals* globals, const XP_UCHAR* str, XP_Bool palmask( PalmAppGlobals* globals, const XP_UCHAR* str,
const XP_UCHAR* altButton, XP_S16 titleID ); const XP_UCHAR* altButton, XP_S16 titleID );
void checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr, void checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr,
XWStreamCtxt* instream ); XWStreamCtxt* instream );