#include "FUiCtrl_SearchBarImpl.h"
#include "FUiCtrl_EditFieldImpl.h"
#include "FUiCtrl_ButtonImpl.h"
+#include <FSys_SettingInfoImpl.h>
+
using namespace Tizen::Graphics;
using namespace Tizen::Ui;
using namespace Tizen::Base;
using namespace Tizen::Base::Runtime;
using namespace Tizen::Locales;
+using namespace Tizen::System;
namespace Tizen { namespace Ui { namespace Controls
{
, __isupdateContentBounds(false)
, __isKeyPressed(false)
, __isFocusCallbackToBeFired(true)
+ , __isButtonTextChangedByApp(false)
, __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
, __pBackgroundBitmap(null)
, __backgroundColor(Color())
_SearchBar::~_SearchBar(void)
{
+ SettingInfo::RemoveSettingEventListener(*this);
+
delete __pSearchBarPresenter;
__pSearchBarPresenter = null;
__pSearchBarPresenter = pPresenter;
CreateAccessibilityElement();
+
+ r = _SettingInfoImpl::AddSettingEventListener(*this);
+ SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
return r;
CATCH:
SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to set text.");
+ __isButtonTextChangedByApp = true;
+
return r;
}
__pKeypadEvent->Fire(*pEventArg);
}
+ __isKeypadOpening = false;
+
SetContentsArea();
return;
}
bool
_SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
{
+ if (!__pEdit->IsUsbKeyboardConnected())
+ {
+ return false;
+ }
+
+ if (!__pEdit->IsSearchFieldFocused())
+ {
+ return false;
+ }
+
_KeyCode keyCode = keyInfo.GetKeyCode();
- if (keyCode == _KEY_RIGHT)
+ switch (keyCode)
{
- if (GetMode() == SEARCH_BAR_MODE_NORMAL)
- {
- __pEdit->SetFocused();
- return true;
- }
+ case _KEY_RIGHT:
+ SetFocusCallbackParameter(false);
+ if (&source == __pEdit)
+ {
+ if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+ {
+ __pContentControl->SetFocused();
+ __pContentControl->OnDrawFocus();
- if (!__isButtonEnabled || __pCancelButton->IsFocused() || !__isUsableCancelButton)
- {
- return true;
- }
+ return true;
+ }
+ else if (__isButtonEnabled && __isUsableCancelButton)
+ {
+ __pCancelButton->SetFocused();
+ }
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
- SetFocusCallBackParameter(false);
- __pCancelButton->SetFocused();
- __pCancelButton->Invalidate(true);
+ return true;
+ }
- return true;
- }
+ if (&source == __pCancelButton && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
+ {
+ __pContentControl->SetFocused();
+ __pContentControl->OnDrawFocus();
- if (keyCode == _KEY_LEFT)
- {
- if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
- {
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
- __pCancelButton->Invalidate();
- __pEdit->SetFocused();
- }
+ return true;
+ }
- if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
- {
- __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
- SetButtonEnabled(false);
- __pEdit->SetFocused();
- }
+ break;
- return true;
- }
+ case _KEY_LEFT:
+ if (&source == __pCancelButton)
+ {
+ __pEdit->SetFocused();
+ return true;
+ }
+
+ if (&source == __pContentControl)
+ {
+ if ((__isButtonEnabled && __isUsableCancelButton))
+ {
+ __pCancelButton->SetFocused();
+ }
+ else
+ {
+ __pEdit->SetFocused();
+ }
+ return true;
+ }
- if (keyCode == _KEY_ENTER || keyCode == _KEY_TAB)
- {
- if (GetMode() == SEARCH_BAR_MODE_NORMAL)
- {
- return false;
- }
+ break;
- SetMode(SEARCH_BAR_MODE_NORMAL);
- __isKeyPressed = true;
- SetFocused();
+ case _KEY_ENTER:
+ if (&source == __pCancelButton)
+ {
+ SetMode(SEARCH_BAR_MODE_NORMAL);
+ __isKeyPressed = true;
+ SetFocused();
+ _Control::OnDrawFocus();
- return true;
+ return true;
+ }
+
+ break;
+
+ default:
+ return false;
}
return false;
}
+void
+_SearchBar::OnSettingChanged(Tizen::Base::String& key)
+{
+ if (__isButtonTextChangedByApp || !__isUsableCancelButton)
+ {
+ return;
+ }
+
+ if (key.Equals(L"http://tizen.org/setting/locale.language", false))
+ {
+ String cancelText;
+ GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
+ __pCancelButton->SetText(cancelText);
+ __pCancelButton->Invalidate();
+ }
+
+ return;
+}
+
_Control*
_SearchBar::GetParentForm(void) const
{
}
void
-_SearchBar::SetFocusCallBackParameter(bool state)
+_SearchBar::SetFocusCallbackParameter(bool state)
{
__isFocusCallbackToBeFired = state;
return;
}
bool
-_SearchBar::IsFocusCallBackToBeFired(void) const
+_SearchBar::IsFocusCallbackToBeFired(void) const
{
return __isFocusCallbackToBeFired;
}