Skip to content

Commit

Permalink
Fix delete key not functioning correctly in textboxes when text is se…
Browse files Browse the repository at this point in the history
…lected
  • Loading branch information
jacob1 committed Apr 25, 2023
1 parent 8b7a96b commit ad14201
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/gui/interface/Textbox.cpp
Expand Up @@ -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())
Expand All @@ -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)
Expand Down

0 comments on commit ad14201

Please sign in to comment.