From e0085095340ddcac8348433ccf9ce4c994f2050e Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Fri, 1 Sep 2023 12:44:33 +0200 Subject: [PATCH] [MOS-1028] Fix corner case with input mode in Notes app Fix of minor corner case bug in previous implementation - pressing left functional button when selecting input mode would display empty options menu even if note and clipboard were empty. Additionally fixed the same bug for 'Save' button. --- module-apps/application-notes/windows/NoteEditWindow.cpp | 8 ++++---- module-apps/application-notes/windows/NoteEditWindow.hpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/module-apps/application-notes/windows/NoteEditWindow.cpp b/module-apps/application-notes/windows/NoteEditWindow.cpp index b4207ddb9e8d37fbc2f71451868bbe0229d709f6..a69afe570cb495e57678ec2e5efac05c5fd5546e 100644 --- a/module-apps/application-notes/windows/NoteEditWindow.cpp +++ b/module-apps/application-notes/windows/NoteEditWindow.cpp @@ -83,8 +83,8 @@ namespace app::notes })); edit->setTextChangedCallback([this](Item &, const UTF8 &text) { const auto textLength = text.length(); - const auto optionsLabelState = (textLength != 0) || Clipboard::getInstance().hasData(); - navBar->setActive(gui::nav_bar::Side::Left, optionsLabelState); + optionsLabelEnabled = (textLength != 0) || Clipboard::getInstance().hasData(); + navBar->setActive(gui::nav_bar::Side::Left, optionsLabelEnabled); setCharactersCount(textLength); onCharactersCountChanged(textLength); @@ -143,13 +143,13 @@ namespace app::notes bool NoteEditWindow::onInput(const gui::InputEvent &inputEvent) { if (inputEvent.isShortRelease()) { - if (inputEvent.is(gui::KeyCode::KEY_ENTER)) { + if (inputEvent.is(gui::KeyCode::KEY_ENTER) && !edit->getText().empty()) { saveNote(); auto switchData = std::make_unique(notesRecord); switchData->ignoreCurrentWindowOnStack = true; application->switchWindow(gui::name::window::note_preview, std::move(switchData)); } - if (inputEvent.is(gui::KeyCode::KEY_LF) && navBar->isActive(gui::nav_bar::Side::Left)) { + if (inputEvent.is(gui::KeyCode::KEY_LF) && optionsLabelEnabled) { application->switchWindow( window::name::option_window, std::make_unique(noteEditOptions(application, edit))); diff --git a/module-apps/application-notes/windows/NoteEditWindow.hpp b/module-apps/application-notes/windows/NoteEditWindow.hpp index d5c5c02e99e10d4535f923f6c73a284c81e5a612..43ebd16762c5336da43d3d513c5675eddbcf8db5 100644 --- a/module-apps/application-notes/windows/NoteEditWindow.hpp +++ b/module-apps/application-notes/windows/NoteEditWindow.hpp @@ -47,5 +47,6 @@ namespace app::notes std::shared_ptr notesRecord; gui::Label *charactersCounter = nullptr; gui::Text *edit = nullptr; + bool optionsLabelEnabled = false; }; } // namespace app::notes