Make X clear string in keyboard (#226)

This commit is contained in:
Pk11 2023-12-30 18:48:15 -06:00 committed by GitHub
parent a727ca4152
commit 457a82481d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -59,7 +59,7 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
}
font->printf(2 + cursorPosition, labelHeight, false, Alignment::left, Palette::blackWhite, "%s", stringPosition < (int)output.size() ? output.substr(stringPosition, charLen).c_str() : " ");
font->print(firstCol, labelHeight + 2, false, STR_START_RETURN_B_BACKSPACE, alignStart);
font->print(firstCol, labelHeight + 2, false, STR_START_RETURN_B_BACKSPACE_X_CLEAR, alignStart);
font->update(false);
do {
@ -67,7 +67,7 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
pressed = keysDownRepeat();
key = keyboardUpdate();
swiWaitForVBlank();
} while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_START | KEY_TOUCH)) || (key != -1)));
} while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_X | KEY_START | KEY_TOUCH)) || (key != -1)));
switch(key) {
case NOKEY:
@ -176,6 +176,10 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
scrollPosition--;
}
}
} else if(pressed & KEY_X) {
output = "";
stringPosition = 0;
scrollPosition = 0;
} else if(pressed & KEY_START) {
done = true;
}

View File

@ -189,7 +189,7 @@ STRING(A_SELECT_B_CANCEL, "(\\A select, \\B cancel)")
STRING(START_CANCEL, "(START cancel)")
STRING(UDLR_CHANGE_ATTRIBUTES, "(\\D change attributes)")
STRING(A_APPLY_B_CANCEL, "(\\A apply, \\B cancel)")
STRING(START_RETURN_B_BACKSPACE, "(START Return, \\B Backspace)")
STRING(START_RETURN_B_BACKSPACE_X_CLEAR, "(START Return, \\B Backspace, \\X Clear)")
// Byte counts
STRING(1_BYTE, "1 Byte")