From f61241f745e6ad301ff9f17e1cb4466f96cedf56 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 27 May 2019 12:32:23 +0800 Subject: [PATCH] Add onTextUpdated for android soft keyboard input --- src/guiengine/widgets/text_box_widget.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/guiengine/widgets/text_box_widget.cpp b/src/guiengine/widgets/text_box_widget.cpp index 36e1fd6fc..14e022acd 100644 --- a/src/guiengine/widgets/text_box_widget.cpp +++ b/src/guiengine/widgets/text_box_widget.cpp @@ -78,6 +78,9 @@ public: return out; } + PtrVector& + getListeners() { return m_listeners; } + }; using namespace GUIEngine; @@ -270,8 +273,17 @@ ANDROID_EDITTEXT_CALLBACK(ANDROID_PACKAGE_CALLBACK_NAME) dynamic_cast(getFocusForPlayer(0)); if (!tb || (int)widget_id != tb->getID()) return; - tb->getIrrlichtElement()->fromAndroidEditText( - to_editbox, start, end, composing_start, composing_end); + MyCGUIEditBox* eb = tb->getIrrlichtElement(); + if (!eb) + return; + core::stringw old_text = eb->getText(); + eb->fromAndroidEditText(to_editbox, start, end, composing_start, + composing_end); + if (old_text != eb->getText()) + { + for (unsigned n = 0; n < eb->getListeners().size(); n++) + eb->getListeners()[n].onTextUpdated(); + } }); } #endif