Skip to content

Commit eef2942

Browse files
author
Ali Abdul-Karim
committed
Removed base character limit.
Using get int instead of get float on iOS.
1 parent 4cd6bea commit eef2942

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

6 Bytes
Binary file not shown.

release/NativeEditPlugin/Plugins/iOS/EditBox_iOS.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ -(void) create:(JsonObject*)json
188188
float y = [json getFloat:@"y"] * viewController.view.bounds.size.height;
189189
float width = [json getFloat:@"width"] * viewController.view.bounds.size.width;
190190
float height = [json getFloat:@"height"] * viewController.view.bounds.size.height;
191-
characterLimit =[json getFloat:@"characterLimit"];
191+
characterLimit = [json getInt:@"characterLimit"];
192192

193193
float textColor_r = [json getFloat:@"textColor_r"];
194194
float textColor_g = [json getFloat:@"textColor_g"];
@@ -522,7 +522,10 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
522522
}
523523

524524
NSUInteger newLength = [textField.text length] + [string length] - range.length;
525-
return newLength <= characterLimit;
525+
if(characterLimit > 0)
526+
return newLength <= characterLimit;
527+
else
528+
return newLength;
526529
}
527530

528531
-(void) textFieldDidChange :(UITextField *)theTextField{

release/NativeEditPlugin/scripts/NativeEditBox.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public enum ReturnKeyType { Default, Next, Done };
8080
private const string MSG_RETURN_PRESSED = "ReturnPressed";
8181
private const string MSG_GET_TEXT = "GetText";
8282

83-
private const int characterLimitDefault = 40;
84-
8583
public InputField InputField { get { return objUnityInput; } }
8684
public string text
8785
{
@@ -208,11 +206,7 @@ private void PrepareNativeEdit()
208206

209207
mConfig.placeHolder = placeHolder.text;
210208
mConfig.placeHolderColor = placeHolder.color;
211-
212-
if (objUnityInput.characterLimit > 1)
213-
mConfig.characterLimit = objUnityInput.characterLimit;
214-
else
215-
mConfig.characterLimit = characterLimitDefault;
209+
mConfig.characterLimit = objUnityInput.characterLimit;
216210

217211
if (useInputFieldFont)
218212
mConfig.font = objUnityText.font.fontNames.Length > 0 ? objUnityText.font.fontNames[0] : "Arial";

src/androidProj/nativeeditplugin/src/main/java/com/bkmin/android/EditBox.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,15 @@ public void onFocusChange(View v, boolean hasFocus) {
308308
public void afterTextChanged(Editable s)
309309
{
310310
JSONObject jsonToUnity = new JSONObject();
311-
if(s.length() >= characterLimit+1)
311+
312+
if(s.length() >= characterLimit+1 && characterLimit > 0)
312313
{
313314
s.delete(s.length() - 1,
314315
s.length());
315316
edit.setText(s);
316317
edit.setSelection(s.length());
317318
}
319+
318320
try
319321
{
320322
jsonToUnity.put("msg", MSG_TEXT_CHANGE);

0 commit comments

Comments
 (0)