diff --git a/Libraries/LibGUI/SpinBox.cpp b/Libraries/LibGUI/SpinBox.cpp index aecc9f73f9..69da78e293 100644 --- a/Libraries/LibGUI/SpinBox.cpp +++ b/Libraries/LibGUI/SpinBox.cpp @@ -41,6 +41,12 @@ SpinBox::SpinBox() else m_editor->set_text(String::number(m_value)); }; + m_editor->on_up_pressed = [this] { + set_value(m_value + 1); + }; + m_editor->on_down_pressed = [this] { + set_value(m_value - 1); + }; m_increment_button = add(ControlBoxButton::UpArrow); m_increment_button->set_focusable(false); @@ -88,20 +94,6 @@ void SpinBox::set_range(int min, int max) update(); } -void SpinBox::keydown_event(KeyEvent& event) -{ - if (event.key() == KeyCode::Key_Up) { - set_value(m_value + 1); - return; - } - if (event.key() == KeyCode::Key_Down) { - set_value(m_value - 1); - return; - } - - event.ignore(); -} - void SpinBox::mousewheel_event(MouseEvent& event) { set_value(m_value - event.wheel_delta()); diff --git a/Libraries/LibGUI/SpinBox.h b/Libraries/LibGUI/SpinBox.h index 3a8dfa4adc..4fb4a8fcf9 100644 --- a/Libraries/LibGUI/SpinBox.h +++ b/Libraries/LibGUI/SpinBox.h @@ -51,7 +51,6 @@ public: protected: SpinBox(); - virtual void keydown_event(KeyEvent&) override; virtual void mousewheel_event(MouseEvent&) override; virtual void resize_event(ResizeEvent&) override;