fix textbox crash, fix ctrl+c / ctrl+x to not copy an empty string when the textbox is empty

This commit is contained in:
jacob1 2015-09-11 13:08:56 -04:00
parent a629979d8b
commit 81b2efaf5b
2 changed files with 5 additions and 0 deletions

View File

@ -215,6 +215,8 @@ void Label::copySelection()
copyText = currentText.substr(selectionIndex0, selectionIndex1-selectionIndex0).c_str(); copyText = currentText.substr(selectionIndex0, selectionIndex1-selectionIndex0).c_str();
else if(selectionIndex0 > selectionIndex1) else if(selectionIndex0 > selectionIndex1)
copyText = currentText.substr(selectionIndex1, selectionIndex0-selectionIndex1).c_str(); copyText = currentText.substr(selectionIndex1, selectionIndex0-selectionIndex1).c_str();
else if (!currentText.length())
return;
else else
copyText = currentText.c_str(); copyText = currentText.c_str();
ClipboardPush(format::CleanString(copyText, false, true, false)); ClipboardPush(format::CleanString(copyText, false, true, false));

View File

@ -146,8 +146,11 @@ void Textbox::cutSelection()
} }
else else
{ {
if (!backingText.length())
return;
ClipboardPush(format::CleanString(backingText, false, true, false)); ClipboardPush(format::CleanString(backingText, false, true, false));
backingText.clear(); backingText.clear();
cursor = 0;
} }
ClearSelection(); ClearSelection();