diff --git a/LibGUI/GComboBox.cpp b/LibGUI/GComboBox.cpp index a552c4d255..159bfebd40 100644 --- a/LibGUI/GComboBox.cpp +++ b/LibGUI/GComboBox.cpp @@ -13,6 +13,10 @@ GComboBox::GComboBox(GWidget* parent) if (on_change) on_change(m_editor->text()); }; + m_editor->on_return_pressed = [this] { + if (on_return_pressed) + on_return_pressed(); + }; m_open_button = new GButton(this); m_open_button->set_focusable(false); m_open_button->set_text("\xf7"); @@ -84,9 +88,15 @@ void GComboBox::open() void GComboBox::close() { m_list_window->hide(); + m_editor->set_focus(true); } String GComboBox::text() const { return m_editor->text(); } + +void GComboBox::set_text(const String& text) +{ + m_editor->set_text(text); +} diff --git a/LibGUI/GComboBox.h b/LibGUI/GComboBox.h index 7d70fe2ae5..d892f1cd57 100644 --- a/LibGUI/GComboBox.h +++ b/LibGUI/GComboBox.h @@ -12,6 +12,7 @@ public: virtual ~GComboBox() override; String text() const; + void set_text(const String&); void open(); void close(); @@ -21,6 +22,7 @@ public: void set_model(NonnullRefPtr); Function on_change; + Function on_return_pressed; virtual const char* class_name() const override { return "GComboBox"; }