- 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));
|
||||
|
||||
//if(key == vkBack) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
||||
string text = labelServerIp.getText();
|
||||
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__);
|
||||
string text= labelServerIp.getText();
|
||||
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end()-2);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
labelServerIp.setText(text);
|
||||
|
|
|
@ -941,12 +941,18 @@ bool MenuStateOptions::isInSpecialKeyCaptureEvent() {
|
|||
|
||||
void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel != NULL) {
|
||||
//if(key == vkBack) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
||||
string text= activeInputLabel->getText();
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end()-2);
|
||||
string text= activeInputLabel->getText();
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true && 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user