~aleteoryx/muditaos

8d796d8a0b0c8aaea3965c01d79ec86d9a4e1180 — Bartosz 3 years ago 27cf193
[MOS-757] Fixed backspace behavior

Now backspace (held # button) removes everything from
beginning up to the cursor

Coauthored with @Lefucjusz
3 files changed, 18 insertions(+), 1 deletions(-)

M module-gui/gui/widgets/text/Text.cpp
M module-gui/gui/widgets/text/Text.hpp
M pure_changelog.md
M module-gui/gui/widgets/text/Text.cpp => module-gui/gui/widgets/text/Text.cpp +16 -1
@@ 186,6 186,21 @@ namespace gui
        drawLines();
    }

    void Text::removeFromCursor()
    {
        const auto currentText    = getText();
        const auto cursorPosition = cursor->getAbsolutePosition();
        const auto substrLength   = currentText.length() - cursorPosition;

        const auto newText = currentText.substr(cursorPosition, substrLength);
        buildDocument(newText);

        /* Rewind cursor to the beginning of the line */
        cursor->moveCursor(NavigationDirection::LEFT, cursorPosition);

        onTextChanged();
    }

    void Text::clear()
    {
        buildDocument("");


@@ 634,7 649,7 @@ namespace gui
        }
        if (inputEvent.isLongRelease(removeKey)) {
            if (!document->isEmpty()) {
                clear();
                removeFromCursor();
                return true;
            }
        }

M module-gui/gui/widgets/text/Text.hpp => module-gui/gui/widgets/text/Text.hpp +1 -0
@@ 149,6 149,7 @@ namespace gui
        /// add rich text with default RichTextParser - please see RichTextParser documentation on how to use format
        void addRichText(const UTF8 &text, text::RichTextParser::TokenMap &&tokens = text::RichTextParser::TokenMap{});
        /// @}
        void removeFromCursor();
        virtual void clear();
        bool isEmpty();
        virtual UTF8 getText() const;

M pure_changelog.md => pure_changelog.md +1 -0
@@ 12,6 12,7 @@
* Fixed adding and deleting country code prefix to existing contact
* Fixed French translation for SIM cards texts
* Fixed crash on music file with invalid tags
* Fixed backspace behavior in text edit

### Added