Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep text in TextArea when used in TabView #5599

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions QMLComponents/controls/textareabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,19 @@ void TextAreaBase::termsChangedHandler()
{
if ((_textType == TextType::TextTypeLavaan || _textType == TextType::TextTypeCSem) && form() && initialized())
form()->refreshAnalysis();
}

void TextAreaBase::_setInitialized(const Json::Value &value)
{
// The text in the TextArea is not stored in the bound value (it is stored only after an applyRequest call)
// So if the TextArea is re-initialized, it will lose its current value.
// This is the case when a TextArea is used in a TabView: when adding or removing a tab, the TabView may re-initialized its controls.
// So in this case, just keep the current text, and reset it after the initialization
QString currentText = text();
bool keepText = initialized();

JASPListControl::_setInitialized(value);

if (keepText)
setText(currentText);
}
1 change: 1 addition & 0 deletions QMLComponents/controls/textareabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected slots:
void termsChangedHandler() override;

protected:
void _setInitialized(const Json::Value& value = Json::nullValue) override;

BoundControlTextArea* _boundControl = nullptr;
TextType _textType = TextType::TextTypeDefault;
Expand Down
Loading