@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "TextLineCursor.hpp"
@@ 220,6 220,10 @@ namespace gui
if (direction == NavigationDirection::DOWN) {
+ if (checkNextLineDocumentEnd(selectedLineNumber)) {
+ return TextCursor::Move::End;
+ }
+
handleDownNavigation(selectedLineNumber, selectedLineCursorPosition);
debug_text_cursor("After move cursor: screen pos: %d block: %d pos: %d %s",
@@ 18,6 18,7 @@
#include <RawFont.hpp>
#include "Font.hpp"
#include "RichTextParser.hpp"
+#include "TextFixedSize.hpp"
TEST_CASE("Text ctor")
{
@@ 1330,3 1331,41 @@ TEST_CASE("RichText newline and empty lines tests")
REQUIRE((*text->lineGet(2)).getText(0) == "");
}
}
+
+TEST_CASE("Navigating down between input texts")
+{
+ using namespace gui;
+ const InputEvent keyDown{{}, InputEvent::State::keyReleasedShort, KeyCode::KEY_DOWN};
+
+ mockup::fontManager();
+ SECTION("Empty texts")
+ {
+ auto layout = VBox(nullptr, 0, 0, 100, 200);
+ [[maybe_unused]] auto text1 = new TextFixedSize(&layout, 0, 0, 100, 150);
+ [[maybe_unused]] auto text2 = new TextFixedSize(&layout, 0, 150, 100, 50);
+ layout.setFocus(true);
+
+ REQUIRE(layout.getFocusItemIndex() == 0);
+
+ layout.onInput(keyDown);
+ REQUIRE(layout.getFocusItemIndex() == 1);
+ }
+
+ SECTION("Non-empty texts and no new line at the end [EGD-7047]")
+ {
+ constexpr auto testString = "Test String";
+
+ auto layout = VBox(nullptr, 0, 0, 100, 200);
+ auto text1 = new TextFixedSize(&layout, 0, 0, 100, 150);
+ text1->addText(TextBlock(testString, Font(27).raw(), TextBlock::End::None));
+ text1->setCursorStartPosition(CursorStartPosition::DocumentBegin);
+
+ [[maybe_unused]] auto text2 = new TextFixedSize(&layout, 0, 150, 100, 50);
+ layout.setFocus(true);
+
+ REQUIRE(layout.getFocusItemIndex() == 0);
+
+ layout.onInput(keyDown);
+ REQUIRE(layout.getFocusItemIndex() == 1);
+ }
+}