mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
TextEditComponent will now return an empty string if only whitespace characters were entered.
This commit is contained in:
parent
527b9321b5
commit
fc08a83fa0
|
@ -84,6 +84,22 @@ void TextEditComponent::textInput(const std::string& text)
|
||||||
onCursorChanged();
|
onCursorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TextEditComponent::getValue() const
|
||||||
|
{
|
||||||
|
if (mText.empty())
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// If mText only contains whitespace characters, then return an empty string.
|
||||||
|
if (std::find_if(mText.cbegin(), mText.cend(), [](char c) {
|
||||||
|
return !std::isspace(static_cast<unsigned char>(c));
|
||||||
|
}) == mText.cend()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return mText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditComponent::startEditing()
|
void TextEditComponent::startEditing()
|
||||||
{
|
{
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
void setValue(const std::string& val) override;
|
void setValue(const std::string& val) override;
|
||||||
std::string getValue() const override { return mText; }
|
std::string getValue() const override;
|
||||||
|
|
||||||
void startEditing();
|
void startEditing();
|
||||||
void stopEditing();
|
void stopEditing();
|
||||||
|
|
Loading…
Reference in a new issue