Skip to content

Commit

Permalink
Make X clear string in keyboard (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicpkmn11 authored Dec 31, 2023
1 parent a727ca4 commit 457a824
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions arm9/source/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ 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 {
scanKeys();
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:
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/language.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 457a824

Please sign in to comment.