proper ctrl+backspace support

This commit is contained in:
jacob1 2017-05-08 23:45:18 -04:00
parent abf60508cd
commit 0f40db4ef9

View File

@ -358,7 +358,12 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
else if (backingText.length() && cursor < (int)backingText.length())
{
if (ctrl)
backingText.erase(cursor, backingText.length()-cursor);
{
size_t stopChar;
stopChar = backingText.find_first_not_of(" .,!?\n", cursor);
stopChar = backingText.find_first_of(" .,!?\n", stopChar);
backingText.erase(cursor, stopChar-cursor);
}
else
backingText.erase(cursor, 1);
changed = true;
@ -380,8 +385,14 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
if (ctrl)
{
backingText.erase(0, cursor);
cursor = 0;
size_t stopChar;
stopChar = backingText.substr(0, cursor).find_last_not_of(" .,!?\n");
if (stopChar == backingText.npos)
stopChar = -1;
else
stopChar = backingText.substr(0, stopChar).find_last_of(" .,!?\n");
backingText.erase(stopChar+1, cursor-(stopChar+1));
cursor = stopChar+1;
}
else
{