~aleteoryx/muditaos

e0085095340ddcac8348433ccf9ce4c994f2050e — Lefucjusz 2 years ago ddc1c64
[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.
M module-apps/application-notes/windows/NoteEditWindow.cpp => module-apps/application-notes/windows/NoteEditWindow.cpp +4 -4
@@ 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<NoteSwitchData>(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<gui::OptionsWindowOptions>(noteEditOptions(application, edit)));

M module-apps/application-notes/windows/NoteEditWindow.hpp => module-apps/application-notes/windows/NoteEditWindow.hpp +1 -0
@@ 47,5 47,6 @@ namespace app::notes
        std::shared_ptr<NotesRecord> notesRecord;
        gui::Label *charactersCounter = nullptr;
        gui::Text *edit               = nullptr;
        bool optionsLabelEnabled      = false;
    };
} // namespace app::notes