From e1c86d668b32e33ea1605076ed8a744d0858737d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AC=E6=A6=86=E5=A4=A7=E5=8F=94?= Date: Thu, 24 Nov 2022 09:46:16 +0800 Subject: [PATCH] Fix composed character on multiline EditBox (#11263) Co-authored-by: pandamicro --- native/cocos/ui/edit-box/EditBox-ios.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/native/cocos/ui/edit-box/EditBox-ios.mm b/native/cocos/ui/edit-box/EditBox-ios.mm index 06eb1aea71..e5201e5da4 100644 --- a/native/cocos/ui/edit-box/EditBox-ios.mm +++ b/native/cocos/ui/edit-box/EditBox-ios.mm @@ -222,8 +222,10 @@ void onParentViewTouched(const cc::CustomEvent &touchEvent){ return; // check length limit after text changed, a little rude - if (textView.text.length > g_maxLength) - textView.text = [textView.text substringToIndex:g_maxLength]; + if (textView.text.length > g_maxLength) { + NSRange rangeIndex = [textView.text rangeOfComposedCharacterSequenceAtIndex:g_maxLength]; + textView.text = [textView.text substringToIndex:rangeIndex.location]; + } tViewOnView.text = textView.text; tViewOnToolbar.text = textView.text; callJSFunc("input", [textView.text UTF8String]);