mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
Fix delete key not functioning correctly in textboxes when text is selected
This commit is contained in:
@@ -360,10 +360,11 @@ void Textbox::OnVKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl,
|
||||
StopTextEditing();
|
||||
if (HasSelection())
|
||||
{
|
||||
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
|
||||
int lowerBound = getLowerSelectionBound(), higherBound = getHigherSelectionBound();
|
||||
if (lowerBound < 0 || higherBound > (int)backingText.length())
|
||||
return;
|
||||
backingText.Erase(getLowerSelectionBound(), getHigherSelectionBound());
|
||||
cursor = getLowerSelectionBound();
|
||||
backingText.Erase(lowerBound, higherBound - lowerBound);
|
||||
cursor = lowerBound;
|
||||
changed = true;
|
||||
}
|
||||
else if (backingText.length() && cursor < (int)backingText.length())
|
||||
@@ -387,10 +388,11 @@ void Textbox::OnVKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl,
|
||||
StopTextEditing();
|
||||
if (HasSelection())
|
||||
{
|
||||
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
|
||||
int lowerBound = getLowerSelectionBound(), higherBound = getHigherSelectionBound();
|
||||
if (lowerBound < 0 || higherBound > (int)backingText.length())
|
||||
return;
|
||||
backingText.erase(backingText.begin()+getLowerSelectionBound(), backingText.begin()+getHigherSelectionBound());
|
||||
cursor = getLowerSelectionBound();
|
||||
backingText.Erase(lowerBound, higherBound - lowerBound);
|
||||
cursor = lowerBound;
|
||||
changed = true;
|
||||
}
|
||||
else if (backingText.length() && cursor > 0)
|
||||
|
Reference in New Issue
Block a user