Merge pull request #13217 from jianglong0156/fixTextFieldBug

fix textfield and editbox can not input emoticon
This commit is contained in:
pandamicro 2015-08-05 17:41:19 +08:00
commit 881adf6f36
3 changed files with 8 additions and 5 deletions

View File

@ -80,7 +80,7 @@ CC_DLL bool UTF16ToUTF8(const std::u16string& utf16, std::string& outUtf8);
* because getStringUTFChars can not pass special emoticon
* @param env The JNI Env
* @param srcjStr The jstring which want to convert
* @param ret True if convert success, if ret not null
* @param ret True if the conversion succeeds and the ret pointer isn't null
* @returns the result of utf8 string
*/
CC_DLL std::string getStringUTFCharsJNI(JNIEnv* env, jstring srcjStr, bool* ret = nullptr);
@ -90,7 +90,7 @@ CC_DLL std::string getStringUTFCharsJNI(JNIEnv* env, jstring srcjStr, bool* ret
* because newStringUTF can not convert special emoticon
* @param env The JNI Env
* @param srcjStr The std::string which want to convert
* @param ret True if convert success, if ret not null
* @param ret True if the conversion succeeds and the ret pointer isn't null
* @returns the result of jstring,the jstring need to DeleteLocalRef(jstring);
*/
CC_DLL jstring newStringUTFJNI(JNIEnv* env, std::string utf8Str, bool* ret = nullptr);

View File

@ -32,6 +32,8 @@ THE SOFTWARE.
#include "deprecated/CCString.h"
#include "Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include "base/ccUTF8.h"
#define LOG_TAG "Java_org_cocos2dx_lib_Cocos2dxHelper.cpp"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
@ -117,12 +119,13 @@ void showEditTextDialogJNI(const char* title, const char* message, int inputMode
jstring stringArg1;
if (!title) {
stringArg1 = t.env->NewStringUTF("");
} else {
stringArg1 = t.env->NewStringUTF(title);
stringArg1 = cocos2d::StringUtils::newStringUTFJNI(t.env, title);
}
jstring stringArg2 = t.env->NewStringUTF(message);
jstring stringArg2 = cocos2d::StringUtils::newStringUTFJNI(t.env, message);
t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2,inputMode, inputFlag, returnType, maxLength);

View File

@ -51,6 +51,6 @@ extern "C" {
return 0;
}
std::string pszText = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText();
return env->NewStringUTF(pszText.c_str());
return cocos2d::StringUtils::newStringUTFJNI(env, pszText);
}
}