Skip to content

Commit

Permalink
Text widget: Remove one-pixel cursor extension on top and bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Jul 7, 2024
1 parent 283e842 commit b453efd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Source/Core/Elements/WidgetTextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ Vector2f WidgetTextInput::FormatText(float height_constraint)
void WidgetTextInput::GenerateCursor()
{
cursor_size.x = Math::Round(ElementUtilities::GetDensityIndependentPixelRatio(text_element));
cursor_size.y = GetLineHeight() + 2.0f;
cursor_size.y = GetLineHeight();

Colourb color = parent->GetComputedValues().color();

Expand Down Expand Up @@ -1449,7 +1449,7 @@ void WidgetTextInput::UpdateCursorPosition(bool update_ideal_cursor_position)

cursor_position = {
(float)string_width_pre_cursor + alignment_offset,
-1.f + (float)cursor_line_index * GetLineHeight(),
(float)cursor_line_index * GetLineHeight(),
};

const bool word_wrap = parent->GetComputedValues().white_space() == Style::WhiteSpace::Prewrap;
Expand Down Expand Up @@ -1569,12 +1569,10 @@ void WidgetTextInput::SetKeyboardActive(bool active)
{
if (active)
{
// Activate the keyboard and submit the cursor position and line height to enable clients to adjust the input method editor (IME). Note
// that the cursor is extended by one pixel along the top and bottom, we reverse this extension here.
// Activate the keyboard and submit the cursor position and line height to enable clients to adjust the input method editor (IME).
const Vector2f element_offset = parent->GetAbsoluteOffset() - scroll_offset;
const Vector2f absolute_cursor_position = element_offset + cursor_position + Vector2f(0, 1);
const float line_height = cursor_size.y - 2.f;
system->ActivateKeyboard(absolute_cursor_position, line_height);
const Vector2f absolute_cursor_position = element_offset + cursor_position;
system->ActivateKeyboard(absolute_cursor_position, cursor_size.y);
}
else
{
Expand Down

0 comments on commit b453efd

Please sign in to comment.