From 391b61be95c31af5727457daafa583cd621a7226 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 28 May 2019 14:24:45 +0800 Subject: [PATCH] Fix highlighting of composing text in the middle of sentence --- android/src/main/java/STKEditText.java | 2 +- src/guiengine/widgets/CGUIEditBox.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/STKEditText.java b/android/src/main/java/STKEditText.java index 0cadc85c3..b2b20a700 100644 --- a/android/src/main/java/STKEditText.java +++ b/android/src/main/java/STKEditText.java @@ -23,7 +23,7 @@ public class STKEditText extends EditText /* Used to prevent copying text to non focused widget in STK. */ private int m_stk_widget_id; - STKInputConnection m_stk_input_connection; + private STKInputConnection m_stk_input_connection; /* Used to avoid infinite calling updateSTKEditBox if setText currently * by jni. */ diff --git a/src/guiengine/widgets/CGUIEditBox.cpp b/src/guiengine/widgets/CGUIEditBox.cpp index f424103d8..5f2205746 100644 --- a/src/guiengine/widgets/CGUIEditBox.cpp +++ b/src/guiengine/widgets/CGUIEditBox.cpp @@ -1086,6 +1086,13 @@ void CGUIEditBox::draw() s32 underline_begin = font->getDimension(s.c_str()).Width; core::rect underline = CurrentTextRect; underline.UpperLeftCorner.X += underline_begin; + s32 end_length = m_composing_end - m_composing_start; + if (end_length > 0 && end_length != (s32)Text.size()) + { + s = txtLine->subString(m_composing_start, end_length); + s32 underline_end = font->getDimension(s.c_str()).Width; + underline.LowerRightCorner.X = underline.UpperLeftCorner.X + underline_end; + } s32 height = underline.LowerRightCorner.Y - underline.UpperLeftCorner.Y; underline.UpperLeftCorner.Y += s32(std::abs(height) * 0.9f); underline.LowerRightCorner.Y -= s32(std::abs(height) * 0.08f);