diff --git a/Libraries/LibGUI/ComboBox.cpp b/Libraries/LibGUI/ComboBox.cpp index 62461a83996..160994c8fa5 100644 --- a/Libraries/LibGUI/ComboBox.cpp +++ b/Libraries/LibGUI/ComboBox.cpp @@ -35,9 +35,28 @@ namespace GUI { +class ComboBoxEditor final : public TextEditor { + C_OBJECT(ComboBoxEditor); + +public: + Function on_mousewheel; + +private: + ComboBoxEditor() + : TextEditor(TextEditor::SingleLine) + { + } + + virtual void mousewheel_event(MouseEvent& event) override + { + if (on_mousewheel) + on_mousewheel(event.wheel_delta()); + } +}; + ComboBox::ComboBox() { - m_editor = add(); + m_editor = add(); m_editor->on_change = [this] { if (on_change) on_change(m_editor->text(), m_list_view->selection().first()); @@ -74,6 +93,10 @@ ComboBox::ComboBox() on_change(m_editor->text(), index); }); }; + + m_editor->on_mousewheel = [this](int delta) { + m_list_view->move_selection(delta); + }; } ComboBox::~ComboBox() diff --git a/Libraries/LibGUI/ComboBox.h b/Libraries/LibGUI/ComboBox.h index 8e3232996b7..bb8d51877b6 100644 --- a/Libraries/LibGUI/ComboBox.h +++ b/Libraries/LibGUI/ComboBox.h @@ -30,6 +30,8 @@ namespace GUI { +class ComboBoxEditor; + class ComboBox : public Widget { C_OBJECT(ComboBox) public: @@ -62,7 +64,7 @@ protected: virtual void resize_event(ResizeEvent&) override; private: - RefPtr m_editor; + RefPtr m_editor; RefPtr