diff options
Diffstat (limited to 'Userland/Libraries/LibGUI/InputBox.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/InputBox.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp index 0fffa1e9dc..1bc8b9478e 100644 --- a/Userland/Libraries/LibGUI/InputBox.cpp +++ b/Userland/Libraries/LibGUI/InputBox.cpp @@ -15,9 +15,9 @@ namespace GUI { -InputBox::InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type) +InputBox::InputBox(Window* parent_window, String text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type) : Dialog(parent_window) - , m_text_value(text_value) + , m_text_value(move(text_value)) , m_prompt(prompt) , m_placeholder(placeholder) { @@ -36,6 +36,17 @@ Dialog::ExecResult InputBox::show(Window* parent_window, String& text_value, Str return result; } +void InputBox::set_text_value(String text_value) +{ + m_text_editor->set_text(move(text_value)); +} + +void InputBox::on_done(ExecResult result) +{ + if (result == ExecResult::OK) + m_text_value = m_text_editor->text(); +} + void InputBox::build(InputType input_type) { auto& widget = set_main_widget<Widget>(); @@ -86,7 +97,6 @@ void InputBox::build(InputType input_type) m_ok_button->set_text("OK"); m_ok_button->on_click = [this](auto) { dbgln("GUI::InputBox: OK button clicked"); - m_text_value = m_text_editor->text(); done(ExecResult::OK); }; m_ok_button->set_default(true); |