Browse Source

TextEditor: Change caret positioning when clicking before text and between lines

This commit fixes an issue when using large lineSpacing, where the caret
would jump to the end of the previous line when clicking between lines.
With the new behaviour the line spacing is considered to belong to the
previous line.

The commit also changes the behaviour observed when clicking in the
empty space before the first line. Until now the caret would jump into
the first character position. Now it behaves as if the space before the
first line would belong to the first line.
v7.0.9
attila 2 years ago
parent
commit
d564e49312
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      modules/juce_gui_basics/widgets/juce_TextEditor.cpp

+ 2
- 2
modules/juce_gui_basics/widgets/juce_TextEditor.cpp View File

@@ -2614,9 +2614,9 @@ int TextEditor::indexAtPosition (const float x, const float y) const
{
for (Iterator i (*this); i.next();)
{
if (y < i.lineY + i.lineHeight)
if (y < i.lineY + (i.lineHeight * lineSpacing))
{
if (y < i.lineY)
if (jmax (0.0f, y) < i.lineY)
return jmax (0, i.indexInText - 1);
if (x <= i.atomX || i.atom->isNewLine())


Loading…
Cancel
Save