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