mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
LibGUI: Make NumericInput respond to the mouse wheel
Scroll the mouse wheel over a NumericInput to quickly change the value. This matches the SpinBox behavior.
This commit is contained in:
parent
4b96136803
commit
da349607a3
2 changed files with 11 additions and 0 deletions
|
@ -90,4 +90,13 @@ void NumericInput::set_current_number(i64 number, GUI::AllowCallback allow_callb
|
|||
on_number_changed(m_current_number);
|
||||
}
|
||||
|
||||
void NumericInput::mousewheel_event(GUI::MouseEvent& event)
|
||||
{
|
||||
auto wheel_delta = event.wheel_delta_y() / abs(event.wheel_delta_y());
|
||||
if (event.modifiers() == KeyModifier::Mod_Ctrl)
|
||||
wheel_delta *= 6;
|
||||
set_current_number(m_current_number - wheel_delta);
|
||||
event.accept();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
void set_max_number(i64 number);
|
||||
void set_current_number(i64 number, GUI::AllowCallback allow_callback = GUI::AllowCallback::Yes);
|
||||
|
||||
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
||||
|
||||
private:
|
||||
NumericInput();
|
||||
void on_focus_lost();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue