Hi!
I am currently trying to implement deleting characters from a text field in C++. If the user hits Backspace, the following code is executed. There is currently no cursor, it should just remove the last character...
if (mText.length() > 0){
mText.erase( mText.length() - 1, 1);
// mText.resize(mText.length() - 1);
}
This works fine the first time, but if you hit Backspace again, it does not remove anything.
I printed the mText.length()
and it shows that the length never changes. I tried to resize()
the string, it works fine, but the first time I hit Backspace it removes 2 characters.
I hope someone can explain this behaviour and help me solving the problem. I dont know much about memory allocation, so please be patient with me ;)
Thanks
opatut