diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2018-11-23 14:07:48 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2018-11-23 14:07:48 +0200 |
commit | 4554c682e6c9749116c79313d6f08cd6e8b7e6e6 (patch) | |
tree | ca6f01129c89cd85eb6dd9b065a90a976c30ba44 /core | |
parent | 8ba0d513fa0068a241a25fbb6db09315fa3309cc (diff) |
Changes IME input to use notification instead of callback, exposes IME methods to gdscript/gdnative.
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 15 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/os/main_loop.cpp | 1 | ||||
-rw-r--r-- | core/os/main_loop.h | 1 | ||||
-rw-r--r-- | core/os/os.h | 3 |
5 files changed, 19 insertions, 3 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0032c43179..8641af84d9 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -378,12 +378,20 @@ bool _OS::get_borderless_window() const { void _OS::set_ime_active(const bool p_active) { - return OS::get_singleton()->set_ime_active(p_active); + OS::get_singleton()->set_ime_active(p_active); } void _OS::set_ime_position(const Point2 &p_pos) { - return OS::get_singleton()->set_ime_position(p_pos); + OS::get_singleton()->set_ime_position(p_pos); +} + +Point2 _OS::get_ime_selection() const { + return OS::get_singleton()->get_ime_selection(); +} + +String _OS::get_ime_text() const { + return OS::get_singleton()->get_ime_text(); } void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -1134,7 +1142,10 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_window_per_pixel_transparency_enabled"), &_OS::get_window_per_pixel_transparency_enabled); ClassDB::bind_method(D_METHOD("set_window_per_pixel_transparency_enabled", "enabled"), &_OS::set_window_per_pixel_transparency_enabled); + ClassDB::bind_method(D_METHOD("set_ime_active", "active"), &_OS::set_ime_active); ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position); + ClassDB::bind_method(D_METHOD("get_ime_selection"), &_OS::get_ime_selection); + ClassDB::bind_method(D_METHOD("get_ime_text"), &_OS::get_ime_text); ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation); ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 720b14bf56..4cdf09d522 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -195,6 +195,8 @@ public: virtual void set_ime_active(const bool p_active); virtual void set_ime_position(const Point2 &p_pos); + virtual Point2 get_ime_selection() const; + virtual String get_ime_text() const; Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); bool native_video_is_playing(); diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 0945cdd512..6e0b914367 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -60,6 +60,7 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED); BIND_CONSTANT(NOTIFICATION_WM_ABOUT); BIND_CONSTANT(NOTIFICATION_CRASH); + BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE); }; void MainLoop::set_init_script(const Ref<Script> &p_init_script) { diff --git a/core/os/main_loop.h b/core/os/main_loop.h index 43f74302a8..e9b331ee45 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -65,6 +65,7 @@ public: NOTIFICATION_TRANSLATION_CHANGED = 90, NOTIFICATION_WM_ABOUT = 91, NOTIFICATION_CRASH = 92, + NOTIFICATION_OS_IME_UPDATE = 93, }; virtual void input_event(const Ref<InputEvent> &p_event); diff --git a/core/os/os.h b/core/os/os.h index 7786ffb26e..9fe300566a 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -242,7 +242,8 @@ public: virtual void set_ime_active(const bool p_active) {} virtual void set_ime_position(const Point2 &p_pos) {} - virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp) {} + virtual Point2 get_ime_selection() const { return Point2(); } + virtual String get_ime_text() const { return String(); } virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; } virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; } |