mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibGUI: Set InputBox initial value to text_value string
This commit is contained in:
parent
3583b62ad3
commit
f10967e364
2 changed files with 6 additions and 4 deletions
|
@ -34,8 +34,9 @@
|
||||||
|
|
||||||
namespace GUI {
|
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)
|
: Dialog(parent_window)
|
||||||
|
, m_text_value(text_value)
|
||||||
, m_prompt(prompt)
|
, m_prompt(prompt)
|
||||||
{
|
{
|
||||||
set_title(title);
|
set_title(title);
|
||||||
|
@ -48,7 +49,7 @@ InputBox::~InputBox()
|
||||||
|
|
||||||
int InputBox::show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title)
|
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);
|
box->set_resizable(false);
|
||||||
if (parent_window)
|
if (parent_window)
|
||||||
box->set_icon(parent_window->icon());
|
box->set_icon(parent_window->icon());
|
||||||
|
@ -81,6 +82,7 @@ void InputBox::build()
|
||||||
|
|
||||||
m_text_editor = label_editor_container.add<TextBox>();
|
m_text_editor = label_editor_container.add<TextBox>();
|
||||||
m_text_editor->set_fixed_height(19);
|
m_text_editor->set_fixed_height(19);
|
||||||
|
m_text_editor->set_text(m_text_value);
|
||||||
|
|
||||||
auto& button_container_outer = widget.add<Widget>();
|
auto& button_container_outer = widget.add<Widget>();
|
||||||
button_container_outer.set_fixed_height(20);
|
button_container_outer.set_fixed_height(20);
|
||||||
|
|
|
@ -38,13 +38,13 @@ public:
|
||||||
static int show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title);
|
static int show(Window* parent_window, String& text_value, const StringView& prompt, const StringView& title);
|
||||||
|
|
||||||
private:
|
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; }
|
String text_value() const { return m_text_value; }
|
||||||
|
|
||||||
void build();
|
void build();
|
||||||
String m_prompt;
|
|
||||||
String m_text_value;
|
String m_text_value;
|
||||||
|
String m_prompt;
|
||||||
|
|
||||||
RefPtr<Button> m_ok_button;
|
RefPtr<Button> m_ok_button;
|
||||||
RefPtr<Button> m_cancel_button;
|
RefPtr<Button> m_cancel_button;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue