- fix backspace deleting in options menu when changing playername and playername has _ in part of it
This commit is contained in:
parent
f3165b2548
commit
96ade03a27
|
@ -527,13 +527,17 @@ void MenuStateJoinGame::keyDown(SDL_KeyboardEvent key) {
|
||||||
|
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
|
|
||||||
//if(key == vkBack) {
|
string text = labelServerIp.getText();
|
||||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
if(isKeyPressed(SDLK_BACKSPACE,key) == true && text.length() > 0) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
string text= labelServerIp.getText();
|
size_t found = text.find_last_of("_");
|
||||||
|
if (found == string::npos) {
|
||||||
if(text.size() > 1) {
|
text.erase(text.end() - 1);
|
||||||
text.erase(text.end()-2);
|
}
|
||||||
|
else {
|
||||||
|
if(text.size() > 1) {
|
||||||
|
text.erase(text.end() - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
labelServerIp.setText(text);
|
labelServerIp.setText(text);
|
||||||
|
|
|
@ -941,12 +941,18 @@ bool MenuStateOptions::isInSpecialKeyCaptureEvent() {
|
||||||
|
|
||||||
void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
|
void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
|
||||||
if(activeInputLabel != NULL) {
|
if(activeInputLabel != NULL) {
|
||||||
//if(key == vkBack) {
|
string text= activeInputLabel->getText();
|
||||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
if(isKeyPressed(SDLK_BACKSPACE,key) == true && text.length() > 0) {
|
||||||
string text= activeInputLabel->getText();
|
size_t found = text.find_last_of("_");
|
||||||
if(text.size() > 1) {
|
if (found == string::npos) {
|
||||||
text.erase(text.end()-2);
|
text.erase(text.end() - 1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if(text.size() > 1) {
|
||||||
|
text.erase(text.end() - 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user