Browse Source

For password TextFields, skip to beginning/end in cursorToPrevWord()/cursorToNextWord().

tags/v2.6.1
Andrew Belt 2 months ago
parent
commit
9dddaefa20
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      src/ui/TextField.cpp

+ 8
- 0
src/ui/TextField.cpp View File

@@ -343,6 +343,10 @@ void TextField::pasteClipboard() {
} }


void TextField::cursorToPrevWord() { void TextField::cursorToPrevWord() {
if (password) {
cursor = 0;
return;
}
// This works for valid UTF-8 text // This works for valid UTF-8 text
size_t pos = text.rfind(' ', std::max(cursor - 2, 0)); size_t pos = text.rfind(' ', std::max(cursor - 2, 0));
if (pos == std::string::npos) if (pos == std::string::npos)
@@ -352,6 +356,10 @@ void TextField::cursorToPrevWord() {
} }


void TextField::cursorToNextWord() { void TextField::cursorToNextWord() {
if (password) {
cursor = text.size();
return;
}
// This works for valid UTF-8 text // This works for valid UTF-8 text
size_t pos = text.find(' ', std::min(cursor + 1, (int) text.size())); size_t pos = text.find(' ', std::min(cursor + 1, (int) text.size()));
if (pos == std::string::npos) if (pos == std::string::npos)


Loading…
Cancel
Save