mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +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();
|
StopTextEditing();
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
{
|
{
|
||||||
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
|
int lowerBound = getLowerSelectionBound(), higherBound = getHigherSelectionBound();
|
||||||
|
if (lowerBound < 0 || higherBound > (int)backingText.length())
|
||||||
return;
|
return;
|
||||||
backingText.Erase(getLowerSelectionBound(), getHigherSelectionBound());
|
backingText.Erase(lowerBound, higherBound - lowerBound);
|
||||||
cursor = getLowerSelectionBound();
|
cursor = lowerBound;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else if (backingText.length() && cursor < (int)backingText.length())
|
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();
|
StopTextEditing();
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
{
|
{
|
||||||
if (getLowerSelectionBound() < 0 || getHigherSelectionBound() > (int)backingText.length())
|
int lowerBound = getLowerSelectionBound(), higherBound = getHigherSelectionBound();
|
||||||
|
if (lowerBound < 0 || higherBound > (int)backingText.length())
|
||||||
return;
|
return;
|
||||||
backingText.erase(backingText.begin()+getLowerSelectionBound(), backingText.begin()+getHigherSelectionBound());
|
backingText.Erase(lowerBound, higherBound - lowerBound);
|
||||||
cursor = getLowerSelectionBound();
|
cursor = lowerBound;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else if (backingText.length() && cursor > 0)
|
else if (backingText.length() && cursor > 0)
|
||||||
|
Reference in New Issue
Block a user