|
@@ -260,14 +260,14 @@ void DisplayServerIOS::touches_cancelled(int p_idx) {
|
|
|
|
|
|
// MARK: Keyboard
|
|
|
|
|
|
-void DisplayServerIOS::key(Key p_key, bool p_pressed) {
|
|
|
+void DisplayServerIOS::key(Key p_key, char32_t p_char, bool p_pressed) {
|
|
|
Ref<InputEventKey> ev;
|
|
|
ev.instantiate();
|
|
|
ev->set_echo(false);
|
|
|
ev->set_pressed(p_pressed);
|
|
|
ev->set_keycode(p_key);
|
|
|
ev->set_physical_keycode(p_key);
|
|
|
- ev->set_unicode((char32_t)p_key);
|
|
|
+ ev->set_unicode(p_char);
|
|
|
perform_event(ev);
|
|
|
}
|
|
|
|
|
@@ -589,6 +589,16 @@ bool DisplayServerIOS::is_touchscreen_available() const {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+_FORCE_INLINE_ int _convert_utf32_offset_to_utf16(const String &p_existing_text, int p_pos) {
|
|
|
+ int limit = p_pos;
|
|
|
+ for (int i = 0; i < MIN(p_existing_text.length(), p_pos); i++) {
|
|
|
+ if (p_existing_text[i] > 0xffff) {
|
|
|
+ limit++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return limit;
|
|
|
+}
|
|
|
+
|
|
|
void DisplayServerIOS::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_length, int p_cursor_start, int p_cursor_end) {
|
|
|
NSString *existingString = [[NSString alloc] initWithUTF8String:p_existing_text.utf8().get_data()];
|
|
|
|
|
@@ -627,8 +637,8 @@ void DisplayServerIOS::virtual_keyboard_show(const String &p_existing_text, cons
|
|
|
|
|
|
[AppDelegate.viewController.keyboardView
|
|
|
becomeFirstResponderWithString:existingString
|
|
|
- cursorStart:p_cursor_start
|
|
|
- cursorEnd:p_cursor_end];
|
|
|
+ cursorStart:_convert_utf32_offset_to_utf16(p_existing_text, p_cursor_start)
|
|
|
+ cursorEnd:_convert_utf32_offset_to_utf16(p_existing_text, p_cursor_end)];
|
|
|
}
|
|
|
|
|
|
void DisplayServerIOS::virtual_keyboard_hide() {
|