- last minute playername editing bugfixes for pressing backspace

This commit is contained in:
Mark Vejvoda 2010-10-08 16:19:09 +00:00
parent e594ba07de
commit 1c32515d7a
2 changed files with 18 additions and 12 deletions

View File

@ -1182,14 +1182,17 @@ bool MenuStateConnectedGame::hasNetworkGameSettings()
void MenuStateConnectedGame::keyDown(char key) {
if(activeInputLabel != NULL) {
if(key == vkBack) {
string text= activeInputLabel->getText();
if(text.size() > 1) {
text.erase(text.end() - 2);
}
if(text.size() == 1) {
string text = activeInputLabel->getText();
if(key == vkBack && text.length() > 0) {
size_t found = text.find_last_of("_");
if (found == string::npos) {
text.erase(text.end() - 1);
}
else {
if(text.size() > 1) {
text.erase(text.end() - 2);
}
}
activeInputLabel->setText(text);

View File

@ -2268,14 +2268,17 @@ void MenuStateCustomGame::updateNetworkSlots() {
void MenuStateCustomGame::keyDown(char key) {
if(activeInputLabel != NULL) {
if(key == vkBack) {
string text = activeInputLabel->getText();
if(text.size() > 1) {
text.erase(text.end() - 2);
}
if(text.size() == 1) {
string text = activeInputLabel->getText();
if(key == vkBack && text.length() > 0) {
size_t found = text.find_last_of("_");
if (found == string::npos) {
text.erase(text.end() - 1);
}
else {
if(text.size() > 1) {
text.erase(text.end() - 2);
}
}
activeInputLabel->setText(text);