mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 13:19:47 +00:00
LibGUI: Use on_up_pressed/on_down_pressed events in SpinBox
Fixes keyboard increment/decrement of SpinBox values. After PR #2412 the TextBox class started not propagating arrow key events to the parent widgets because it handles them itself now. It also added two new events for these arrow keys, so use them instead in SpinBox.
This commit is contained in:
committed by
Andreas Kling
parent
5eefce11ed
commit
1fa5a526e8
@@ -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>(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());
|
||||
|
||||
Reference in New Issue
Block a user