Send message on back key only when coming up, not going down, to

prevent double-dismiss of dialogs.
This commit is contained in:
ehouse 2008-10-18 19:38:31 +00:00
parent c81e85deef
commit bff5f9b7c9
3 changed files with 7 additions and 5 deletions

View file

@ -2397,7 +2397,7 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
exits the app. Bad. So we'll only raise if the exits the app. Bad. So we'll only raise if the
first was not handled. Note that this may well break first was not handled. Note that this may well break
on devices I haven't tested on, later, whenever. */ on devices I haven't tested on, later, whenever. */
&& (0 == (0x1000 & LOWORD(lParam))) ) { && (0 == (BACK_KEY_UP_MAYBE & LOWORD(lParam))) ) {
XP_LOGF( "calling ceSaveAndExit for VK_TBACK" ); XP_LOGF( "calling ceSaveAndExit for VK_TBACK" );
/* I'm actually exiting the app rather than minimize. As /* I'm actually exiting the app rather than minimize. As
it stands, minimizing means that even if I relaunch it stands, minimizing means that even if I relaunch

View file

@ -190,4 +190,6 @@ XP_Bool queryBoxChar( CEAppGlobals* globals, const XP_UCHAR* msg );
(IS_SMARTPHONE(g)?LB_FINDSTRINGEXACT:CB_FINDSTRINGEXACT) (IS_SMARTPHONE(g)?LB_FINDSTRINGEXACT:CB_FINDSTRINGEXACT)
#define LB_IF_PPC(g,id) (IS_SMARTPHONE(g)?id:(id+2)) #define LB_IF_PPC(g,id) (IS_SMARTPHONE(g)?id:(id+2))
#define BACK_KEY_UP_MAYBE 0x1000
#endif /* _CEMAIN_H_ */ #endif /* _CEMAIN_H_ */

View file

@ -407,7 +407,7 @@ ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId )
} }
static XP_Bool static XP_Bool
editHasFocus( const CeDlgHdr* dlgHdr ) editHasFocus( void )
{ {
HWND focus = GetFocus(); HWND focus = GetFocus();
wchar_t buf[32]; wchar_t buf[32];
@ -426,14 +426,14 @@ ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam )
#ifdef OVERRIDE_BACKKEY #ifdef OVERRIDE_BACKKEY
case WM_HOTKEY: case WM_HOTKEY:
if ( VK_TBACK == HIWORD(lParam) ) { if ( VK_TBACK == HIWORD(lParam) ) {
if ( editHasFocus( dlgHdr ) ) { if ( editHasFocus() ) {
SHSendBackToFocusWindow( message, wParam, lParam ); SHSendBackToFocusWindow( message, wParam, lParam );
handled = TRUE; } else if ( 0 != (BACK_KEY_UP_MAYBE & LOWORD(lParam) ) ) {
} else {
WPARAM cmd = (0 != (dlgHdr->doWhat & DLG_STATE_DONEONLY)) ? WPARAM cmd = (0 != (dlgHdr->doWhat & DLG_STATE_DONEONLY)) ?
IDOK : IDCANCEL; IDOK : IDCANCEL;
SendMessage( dlgHdr->hDlg, WM_COMMAND, cmd, 0L ); SendMessage( dlgHdr->hDlg, WM_COMMAND, cmd, 0L );
} }
handled = TRUE;
} }
break; break;
#endif #endif