From 23b88f3bca8737d5abd1fa94ad2bb0df62398402 Mon Sep 17 00:00:00 2001 From: vipul Date: Tue, 2 Jul 2013 20:14:30 +0530 Subject: [PATCH] Esc key handling in MessageBox and ProgressPopup Signed-off-by: vipul Change-Id: Id8f24a48e0329a80782a1651ffe1ad83a7906ce6 --- src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp | 53 ++++++++++++++++++++++--- src/ui/controls/FUiCtrl_ProgressPopup.cpp | 9 +++-- src/ui/inc/FUiCtrl_MessageBoxPresenter.h | 4 +- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp b/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp index 6902a96..1cc9494 100644 --- a/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp +++ b/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp @@ -616,11 +616,19 @@ _MessageBoxPresenter::ProcessEvent(void) FindButtonAndResult(handle); break; } + case MSGBOX_BUTTON_CLOSE: + SetReturnValue(MSGBOX_RESULT_CLOSE); + break; + + case MSGBOX_BUTTON_CANCEL: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + // fall through case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_APP_TERMINATION: case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_CONTINUOUS_TERMINATION: - _ModalLoopManager::GetInstance()->EndMainLoop(exitCode, false); - __beginModal = false; + _ModalLoopManager::GetInstance()->EndMainLoop(exitCode, false); + __beginModal = false; break; } @@ -1443,14 +1451,49 @@ _MessageBoxPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyI if (keyCode == _KEY_ESC || keyCode == _KEY_BACK) { + MessageBoxStyle style = __pMessageBox->GetMsgBoxStyle(); + if ((__pButtonListener->GetBeginModal() == true) || (__beginModal == true)) { - _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_RESULT_CLOSE, false); - __beginModal = false; + if (__pMessageBox->GetTimeout() != 0) + { + switch (style) + { + case MSGBOX_STYLE_NONE: + // fall through + case MSGBOX_STYLE_OK: + // fall through + case MSGBOX_STYLE_YESNO: + // fall through + case MSGBOX_STYLE_ABORTRETRYIGNORE: + _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CLOSE, false); + __beginModal = false; + + break; + case MSGBOX_STYLE_CANCEL: + // fall through + case MSGBOX_STYLE_OKCANCEL: + // fall through + case MSGBOX_STYLE_YESNOCANCEL: + // fall through + case MSGBOX_STYLE_CANCELTRYCONTINUE: + // fall through + case MSGBOX_STYLE_RETRYCANCEL: + _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CANCEL, false); + __beginModal = false; + break; + } + + } + else if (style == MSGBOX_STYLE_CANCEL || style == MSGBOX_STYLE_OKCANCEL || style == MSGBOX_STYLE_YESNOCANCEL + || style == MSGBOX_STYLE_CANCELTRYCONTINUE || style == MSGBOX_STYLE_RETRYCANCEL) + { + _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CANCEL, false); + __beginModal = false; + } } return true; } - return false; } diff --git a/src/ui/controls/FUiCtrl_ProgressPopup.cpp b/src/ui/controls/FUiCtrl_ProgressPopup.cpp index b9d3e06..09d05ea 100644 --- a/src/ui/controls/FUiCtrl_ProgressPopup.cpp +++ b/src/ui/controls/FUiCtrl_ProgressPopup.cpp @@ -1031,11 +1031,14 @@ _ProgressPopup::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) if (keyCode == _KEY_ESC || keyCode == _KEY_BACK) { - FireProgressPopupEvent(); - _Popup::SetReturnValue(POPUP_RESULT_CANCEL); + if (HasButton()) + { + FireProgressPopupEvent(); + _Popup::SetReturnValue(POPUP_RESULT_CANCEL); + } + return true; } - return false; } diff --git a/src/ui/inc/FUiCtrl_MessageBoxPresenter.h b/src/ui/inc/FUiCtrl_MessageBoxPresenter.h index d8ce625..fa10d8c 100644 --- a/src/ui/inc/FUiCtrl_MessageBoxPresenter.h +++ b/src/ui/inc/FUiCtrl_MessageBoxPresenter.h @@ -161,7 +161,9 @@ private: private: enum { - MSGBOX_BUTTON_CLICKED = 0xFF + MSGBOX_BUTTON_CLICKED = 0xFF, + MSGBOX_BUTTON_CLOSE, + MSGBOX_BUTTON_CANCEL }; // Attributes -- 2.7.4