Fix highlighting of composing text in the middle of sentence

This commit is contained in:
Benau 2019-05-28 14:24:45 +08:00
parent 240546ac00
commit 391b61be95
2 changed files with 8 additions and 1 deletions

View File

@ -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. */

View File

@ -1086,6 +1086,13 @@ void CGUIEditBox::draw()
s32 underline_begin = font->getDimension(s.c_str()).Width;
core::rect<s32> 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);