Skip to content

Commit

Permalink
Fix for buffered key queue (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedSobhy01 authored Nov 28, 2023
1 parent aa11e94 commit f359519
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions GUI/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@ string Input::GetString(Output *pO) const
while (1)
{
pWind->WaitKeyPress(Key);
if (Key == 27) // ESCAPE key is pressed
if (Key == 27) { // ESCAPE key is pressed
pWind->FlushKeyQueue();
pWind->FlushMouseQueue();

return ""; // returns nothing as user has cancelled label
if (Key == 13) // ENTER key is pressed
}

if (Key == 13) { // ENTER key is pressed
pWind->FlushKeyQueue();
pWind->FlushMouseQueue();

return Label;
}

if ((Key == 8) && (Label.size() >= 1)) // BackSpace is pressed
Label.resize(Label.size() - 1);
else
Label += Key;

if (pO)
pO->PrintMessage(Label);
}
Expand Down Expand Up @@ -219,6 +230,7 @@ color Input::GetSelectedColor(Output* pO) const // This function reads the posit
}
}

pO->CloseColorMenuWind();
return TRANSPARENT_COLOR;
}
//////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f359519

Please sign in to comment.