diff --git a/cocos2dx/platform/tizen/CCEGLView.cpp b/cocos2dx/platform/tizen/CCEGLView.cpp index 314a967900..5c1ac7f734 100644 --- a/cocos2dx/platform/tizen/CCEGLView.cpp +++ b/cocos2dx/platform/tizen/CCEGLView.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "CCGL.h" #include "CCDirector.h" #include "CCOspApplication.h" +#include "CCOspForm.h" NS_CC_BEGIN using namespace Tizen::App; @@ -88,6 +89,14 @@ void CCEGLView::swapBuffers() void CCEGLView::setIMEKeyboardState(bool bOpen) { + if (bOpen) + { + ((CCOspForm *)CCOspApplication::GetInstance()->getCCOspForm())->ShowKeypad(); + } + else + { + ((CCOspForm *)CCOspApplication::GetInstance()->getCCOspForm())->CloseKeypad(); + } } CCEGLView* CCEGLView::sharedOpenGLView() diff --git a/cocos2dx/platform/tizen/CCOspForm.cpp b/cocos2dx/platform/tizen/CCOspForm.cpp index bbeae97cdc..f57384768d 100644 --- a/cocos2dx/platform/tizen/CCOspForm.cpp +++ b/cocos2dx/platform/tizen/CCOspForm.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "CCOspForm.h" #include "CCDirector.h" #include "CCEGLView.h" +#include "text_input_node/CCIMEDispatcher.h" #include #include @@ -123,7 +124,36 @@ void CCOspForm::OnTextValueChanged(const Tizen::Ui::Control& source) if (buffer) pText = (const char *)buffer->GetPointer(); - m_pfEditTextCallback(pText, m_pCtx); + if (m_pfEditTextCallback) + { + m_pfEditTextCallback(pText, m_pCtx); + } + else + { + const char* pContentText = CCIMEDispatcher::sharedDispatcher()->getContentText(); + + for (unsigned int i = strlen(pContentText); i > 0; i--) + { + CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); + } + + std::string text(""); + if (pText != null) + { + text = pText; + if (text.compare("") == 0) + { + text = "\n"; + } + + if (text.at(text.length() - 1) != '\n') + { + text += '\n'; + } + } + + CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(text.c_str(), text.length()); + } if (buffer) delete buffer; @@ -131,7 +161,19 @@ void CCOspForm::OnTextValueChanged(const Tizen::Ui::Control& source) void CCOspForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source) { - m_pfEditTextCallback("", m_pCtx); + if (m_pfEditTextCallback) + { + m_pfEditTextCallback("", m_pCtx); + } + else + { + const char* pContentText = CCIMEDispatcher::sharedDispatcher()->getContentText(); + + for (unsigned int i = strlen(pContentText); i > 0; i--) + { + CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); + } + } } void @@ -163,6 +205,20 @@ CCOspForm::ShowKeypad(const char* pMessage, KeypadStyle keypadStyle, KeypadInput __pKeypad->Show(); } +void +CCOspForm::ShowKeypad() +{ + ShowKeypad( + CCIMEDispatcher::sharedDispatcher()->getContentText(), + KEYPAD_STYLE_NORMAL, + KEYPAD_MODE_ALPHA, + true, + true, + 100, + null, + null); +} + void CCOspForm::CloseKeypad() { diff --git a/cocos2dx/platform/tizen/CCOspForm.h b/cocos2dx/platform/tizen/CCOspForm.h index a351b0f4e4..35f9d01e16 100644 --- a/cocos2dx/platform/tizen/CCOspForm.h +++ b/cocos2dx/platform/tizen/CCOspForm.h @@ -55,6 +55,7 @@ public: virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); void ShowKeypad(const char* pMessage, Tizen::Ui::Controls::KeypadStyle keypadStyle, Tizen::Ui::Controls::KeypadInputModeCategory keypadCategory, bool bSingleLineEnabled, bool bTextPrediction, int nMaxLength, EditTextCallback pfEditTextCallback, void* pCtx); + void ShowKeypad(); void CloseKeypad(); Tizen::Ui::Controls::Keypad*__pKeypad;