diff --git a/modules/keyboard/src/main/java/com/gluonhq/attach/keyboard/KeyboardType.java b/modules/keyboard/src/main/java/com/gluonhq/attach/keyboard/KeyboardType.java index a214f3f8..50a1557a 100644 --- a/modules/keyboard/src/main/java/com/gluonhq/attach/keyboard/KeyboardType.java +++ b/modules/keyboard/src/main/java/com/gluonhq/attach/keyboard/KeyboardType.java @@ -99,7 +99,16 @@ public enum KeyboardType { /** * A numeric keypad that outputs only ASCII digits */ - ASCII_NUMBER_PAD(11); + ASCII_NUMBER_PAD(11), + + /** + * A text keyboard with autocorrection, suggestions and predictive text + * disabled. Useful for fields that should accept raw user input + * (identifiers, codes, tokens, login input). + * + *
On iOS this value falls back to an ASCII-capable keyboard.
+ */ + TEXT_NO_SUGGESTIONS(12); private final int value; diff --git a/modules/keyboard/src/main/native/ios/Keyboard.m b/modules/keyboard/src/main/native/ios/Keyboard.m index bc6e46b0..7db1bf49 100644 --- a/modules/keyboard/src/main/native/ios/Keyboard.m +++ b/modules/keyboard/src/main/native/ios/Keyboard.m @@ -152,11 +152,17 @@ void setGlassKeyboardType(int type) { JNIEXPORT void JNICALL Java_com_gluonhq_attach_keyboard_impl_IOSKeyboardService_nativeSetKeyboardType (JNIEnv *env, jclass jClass, jint type) { - if (keyboardTypeSwizzled && (UIKeyboardType)type == currentKeyboardType) { + int keyboardType = (int) type; + if (keyboardType < 0 || keyboardType > 11) { + // fall back to an ASCII-capable keyboard. I.e. TEXT_NO_SUGGESTIONS = 12 has no iOS equivalent + keyboardType = (int) UIKeyboardTypeASCIICapable; + } + + if (keyboardTypeSwizzled && (UIKeyboardType)keyboardType == currentKeyboardType) { return; } dispatch_async(dispatch_get_main_queue(), ^{ - setGlassKeyboardType((int)type); + setGlassKeyboardType(keyboardType); reloadKeyboard(); }); }