Skip to content

Commit

Permalink
Fixed textfield caret can't go to end of text...
Browse files Browse the repository at this point in the history
Fixed textfield caret can't go to end of text,
Fixed textfield caret arrow key navigation responsiveness
  • Loading branch information
Neko-Box-Coder committed Aug 29, 2023
1 parent 60d60a8 commit 16b2057
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Src/ssGUI/GUIObjectClasses/TextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,14 @@ namespace ssGUI
{
do
{
if(startPos <= 0 && direction < 0)
if(startPos < 0)
return startPos;

if(startPos == 0 && direction < 0)
return startPos;

if(startPos >= CurrentCharactersDetails.Size() && direction > 0)
return CurrentCharactersDetails.Size() - 1;
return CurrentCharactersDetails.Size();

startPos = startPos + direction;
}
Expand Down Expand Up @@ -249,6 +252,7 @@ namespace ssGUI
if(!inputInterface->IsButtonOrKeyPressExistLastFrame(ssGUI::Enums::SystemKey::LEFT))
{
LastArrowNavStartTime = inputInterface->GetElapsedTime();
LastArrowNavTime = inputInterface->GetElapsedTime();
moveLeft();
}
//When the user is holding down the left arrow key
Expand All @@ -262,7 +266,8 @@ namespace ssGUI
refreshBlinkTimer = true;
blockKeys = true;
}
else if(inputInterface->IsButtonOrKeyPressExistCurrentFrame(ssGUI::Enums::SystemKey::RIGHT))

if(inputInterface->IsButtonOrKeyPressExistCurrentFrame(ssGUI::Enums::SystemKey::RIGHT))
{
auto moveRight = [&]()
{
Expand Down Expand Up @@ -293,6 +298,7 @@ namespace ssGUI
if(!inputInterface->IsButtonOrKeyPressExistLastFrame(ssGUI::Enums::SystemKey::RIGHT))
{
LastArrowNavStartTime = inputInterface->GetElapsedTime();
LastArrowNavTime = inputInterface->GetElapsedTime();
moveRight();
}
//When the user is holding down the right arrow key
Expand Down Expand Up @@ -332,6 +338,7 @@ namespace ssGUI
if(!inputInterface->IsButtonOrKeyPressExistLastFrame(ssGUI::Enums::SystemKey::UP))
{
LastArrowNavStartTime = inputInterface->GetElapsedTime();
LastArrowNavTime = inputInterface->GetElapsedTime();
moveUp();
}
//When the user is holding down the up arrow key
Expand All @@ -345,7 +352,8 @@ namespace ssGUI
refreshBlinkTimer = true;
blockKeys = true;
}
else if(inputInterface->IsButtonOrKeyPressExistCurrentFrame(ssGUI::Enums::SystemKey::DOWN))

if(inputInterface->IsButtonOrKeyPressExistCurrentFrame(ssGUI::Enums::SystemKey::DOWN))
{
auto moveDown = [&]()
{
Expand All @@ -370,6 +378,7 @@ namespace ssGUI
if(!inputInterface->IsButtonOrKeyPressExistLastFrame(ssGUI::Enums::SystemKey::DOWN))
{
LastArrowNavStartTime = inputInterface->GetElapsedTime();
LastArrowNavTime = inputInterface->GetElapsedTime();
moveDown();
}
//When the user is holding down the down arrow key
Expand Down

0 comments on commit 16b2057

Please sign in to comment.