From 6453f7464210a7a49914bad064b4ea781ccc79d4 Mon Sep 17 00:00:00 2001 From: zzLinus <2385747226@qq.com> Date: Mon, 20 Jun 2022 02:16:28 +0800 Subject: [PATCH] LibGUI: Support typing to search for ComboBox LibGUI: Fixup missing one charactor issue --- Userland/Libraries/LibGUI/ComboBox.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index af61cca42d..4ec805d20b 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -25,6 +25,7 @@ class ComboBoxEditor final : public TextEditor { public: Function on_mousewheel; + Function on_keypress; private: ComboBoxEditor() @@ -46,8 +47,10 @@ private: if (is_focused()) set_focus(false); event.accept(); - } else + } else { + on_keypress(event); TextEditor::keydown_event(event); + } } }; @@ -86,6 +89,12 @@ ComboBox::ComboBox() if (only_allow_values_from_model()) m_open_button->click(); }; + m_editor->on_keypress = [this](KeyEvent& event) { + if (!m_list_window->is_visible() && event.key() <= Key_Z && event.key() >= Key_A) { + open(); + m_list_window->event(event); + } + }; m_open_button = add