Fixed a few issues where text editing was not stopped when leaving the text edit popup dialogs

This commit is contained in:
Leon Styhre 2024-02-08 19:20:09 +01:00
parent a8f93cb2bb
commit 2e5f56970a
3 changed files with 16 additions and 7 deletions

View file

@ -130,6 +130,9 @@ std::string TextEditComponent::getValue() const
void TextEditComponent::startEditing() void TextEditComponent::startEditing()
{ {
if (mEditing)
return;
SDL_StartTextInput(); SDL_StartTextInput();
mEditing = true; mEditing = true;
updateHelpPrompts(); updateHelpPrompts();
@ -138,6 +141,9 @@ void TextEditComponent::startEditing()
void TextEditComponent::stopEditing() void TextEditComponent::stopEditing()
{ {
if (!mEditing)
return;
SDL_StopTextInput(); SDL_StopTextInput();
mEditing = false; mEditing = false;
mMaskInput = false; mMaskInput = false;
@ -215,7 +221,7 @@ bool TextEditComponent::input(InputConfig* config, Input input)
moveCursor(mCursorRepeatDir); moveCursor(mCursorRepeatDir);
return false; return false;
} }
else if (cursorDown) { else if (cursorDown && isEditing()) {
// Stop editing and let the button down event be captured by the parent component. // Stop editing and let the button down event be captured by the parent component.
stopEditing(); stopEditing();
return false; return false;
@ -238,6 +244,9 @@ bool TextEditComponent::input(InputConfig* config, Input input)
return true; return true;
} }
if (config->isMappedTo("b", input))
stopEditing();
// Consume all input when editing text. // Consume all input when editing text.
mMaskInput = false; mMaskInput = false;
return true; return true;

View file

@ -378,15 +378,15 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
"", nullptr, nullptr, true)); "", nullptr, nullptr, true));
} }
else { else {
if (mText->isEditing())
mText->stopEditing();
delete this; delete this;
return true; return true;
} }
} }
if (mText->isEditing() && config->isMappedLike("down", input) && input.value) { if (mText->isEditing() && config->isMappedLike("down", input) && input.value)
mText->stopEditing();
mGrid.setCursorTo(mGrid.getSelectedComponent()); mGrid.setCursorTo(mGrid.getSelectedComponent());
}
// Left trigger button outside text editing field toggles Shift key. // Left trigger button outside text editing field toggles Shift key.
if (!mText->isEditing() && config->isMappedLike("lefttrigger", input) && input.value) if (!mText->isEditing() && config->isMappedLike("lefttrigger", input) && input.value)

View file

@ -205,15 +205,15 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input)
"", nullptr, nullptr, true)); "", nullptr, nullptr, true));
} }
else { else {
if (mText->isEditing())
mText->stopEditing();
delete this; delete this;
return true; return true;
} }
} }
if (mText->isEditing() && config->isMappedLike("down", input) && input.value) { if (mText->isEditing() && config->isMappedLike("down", input) && input.value)
mText->stopEditing();
mGrid.setCursorTo(mGrid.getSelectedComponent()); mGrid.setCursorTo(mGrid.getSelectedComponent());
}
// Left shoulder button deletes a character (backspace). // Left shoulder button deletes a character (backspace).
if (config->isMappedTo("leftshoulder", input)) { if (config->isMappedTo("leftshoulder", input)) {