mirror of https://github.com/axmolengine/axmol.git
Implement setIMEKeyboardState function for Tizen.
This commit is contained in:
parent
e48553bc27
commit
ccd20af8f9
|
@ -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()
|
||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
|||
#include "CCOspForm.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "text_input_node/CCIMEDispatcher.h"
|
||||
#include <FBase.h>
|
||||
#include <FText.h>
|
||||
|
||||
|
@ -123,16 +124,57 @@ void CCOspForm::OnTextValueChanged(const Tizen::Ui::Control& source)
|
|||
if (buffer)
|
||||
pText = (const char *)buffer->GetPointer();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void CCOspForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
|
||||
{
|
||||
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
|
||||
CCOspForm::ShowKeypad(const char* pMessage, KeypadStyle keypadStyle, KeypadInputModeCategory keypadCategory, bool bSingleLineEnabled, bool bTextPrediction, int nMaxLength, EditTextCallback pfEditTextCallback, void* pCtx)
|
||||
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue