فهرست منبع

Fix text_entered signal when max_length is used in LineEdit on Android

Fixes #35954

(cherry picked from commit c169367e83abcd606c509d520097265c2b323728)
PouleyKetchoupp 5 سال پیش
والد
کامیت
2e4e1e0324
1فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 13 3
      platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java

+ 13 - 3
platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java

@@ -110,8 +110,13 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
 			@Override
 			public void run() {
 				for (int i = 0; i < count; ++i) {
-					GodotLib.key(0, newChars[i], true);
-					GodotLib.key(0, newChars[i], false);
+					int key = newChars[i];
+					if (key == '\n') {
+						// Return keys are handled through action events
+						continue;
+					}
+					GodotLib.key(0, key, true);
+					GodotLib.key(0, key, false);
 				}
 			}
 		});
@@ -134,8 +139,13 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
 			});
 		}
 
-		if (pActionID == EditorInfo.IME_ACTION_DONE) {
+		if (pActionID == EditorInfo.IME_NULL) {
+			// Enter key has been pressed
+			GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, true);
+			GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, false);
+
 			this.mView.requestFocus();
+			return true;
 		}
 		return false;
 	}