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

View file

@ -378,15 +378,15 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
"", nullptr, nullptr, true));
}
else {
if (mText->isEditing())
mText->stopEditing();
delete this;
return true;
}
}
if (mText->isEditing() && config->isMappedLike("down", input) && input.value) {
mText->stopEditing();
if (mText->isEditing() && config->isMappedLike("down", input) && input.value)
mGrid.setCursorTo(mGrid.getSelectedComponent());
}
// Left trigger button outside text editing field toggles Shift key.
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));
}
else {
if (mText->isEditing())
mText->stopEditing();
delete this;
return true;
}
}
if (mText->isEditing() && config->isMappedLike("down", input) && input.value) {
mText->stopEditing();
if (mText->isEditing() && config->isMappedLike("down", input) && input.value)
mGrid.setCursorTo(mGrid.getSelectedComponent());
}
// Left shoulder button deletes a character (backspace).
if (config->isMappedTo("leftshoulder", input)) {