1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fix key up behaviour in a multiline TextEditor

A regression was introduced in d564e4931. Before that commit you
could use key up to jump into position zero of a multiline TextEditor
if the cursor was somewhere in the first line. Since that commit the
keypress had no effect. This change restores the earlier behaviour.
This commit is contained in:
attila 2022-09-28 15:07:30 +02:00
parent 14628ec824
commit 2e1809ec33

View file

@ -2036,7 +2036,13 @@ bool TextEditor::moveCaretUp (bool selecting)
return moveCaretToStartOfLine (selecting);
const auto caretPos = (getCaretRectangle() - getTextOffset()).toFloat();
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), caretPos.getY() - 1.0f), selecting);
const auto newY = caretPos.getY() - 1.0f;
if (newY < 0.0f)
return moveCaretToStartOfLine (selecting);
return moveCaretWithTransaction (indexAtPosition (caretPos.getX(), newY), selecting);
}
bool TextEditor::moveCaretDown (bool selecting)