1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-11 02:32:07 +00:00

GComboBox: Add set_text() and on_return_pressed hook.

Also give focus back to the editor when closing the list popup window.
This commit is contained in:
Andreas Kling 2019-06-23 07:55:28 +02:00
parent 0af61e9123
commit 1d0ada32cc
2 changed files with 12 additions and 0 deletions

View file

@ -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);
}