LibGUI: Set InputBox initial value to text_value string

This commit is contained in:
Linus Groh 2021-02-20 12:04:15 +01:00 committed by Andreas Kling
parent 3583b62ad3
commit f10967e364
2 changed files with 6 additions and 4 deletions

View file

@ -34,8 +34,9 @@
namespace GUI {
InputBox::InputBox(Window* parent_window, const StringView& prompt, const StringView& title)
InputBox::InputBox(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title)
: Dialog(parent_window)
, m_text_value(text_value)
, m_prompt(prompt)
{
set_title(title);
@ -48,7 +49,7 @@ InputBox::~InputBox()
int InputBox::show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title)
{
auto box = InputBox::construct(parent_window, prompt, title);
auto box = InputBox::construct(parent_window, text_value, prompt, title);
box->set_resizable(false);
if (parent_window)
box->set_icon(parent_window->icon());
@ -81,6 +82,7 @@ void InputBox::build()
m_text_editor = label_editor_container.add<TextBox>();
m_text_editor->set_fixed_height(19);
m_text_editor->set_text(m_text_value);
auto& button_container_outer = widget.add<Widget>();
button_container_outer.set_fixed_height(20);

View file

@ -38,13 +38,13 @@ public:
static int show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title);
private:
explicit InputBox(Window* parent_window, const StringView& prompt, const StringView& title);
explicit InputBox(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title);
String text_value() const { return m_text_value; }
void build();
String m_prompt;
String m_text_value;
String m_prompt;
RefPtr<Button> m_ok_button;
RefPtr<Button> m_cancel_button;