GUI: Give MouseEvent shift() / ctrl() / alt() / logo() functions

This commit is contained in:
Nico Weber 2020-08-11 21:01:00 -04:00 committed by Andreas Kling
parent eab7712ab0
commit cb2d56b909
Notes: sideshowbarker 2024-07-19 03:52:34 +09:00
2 changed files with 5 additions and 1 deletions

View file

@ -331,6 +331,10 @@ public:
int y() const { return m_position.y(); }
MouseButton button() const { return m_button; }
unsigned buttons() const { return m_buttons; }
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
bool logo() const { return m_modifiers & Mod_Logo; }
unsigned modifiers() const { return m_modifiers; }
int wheel_delta() const { return m_wheel_delta; }

View file

@ -61,7 +61,7 @@ void ScrollableWidget::mousewheel_event(MouseEvent& event)
return;
}
// FIXME: The wheel delta multiplier should probably come from... somewhere?
if (event.modifiers() & Mod_Shift) {
if (event.shift()) {
horizontal_scrollbar().set_value(horizontal_scrollbar().value() + event.wheel_delta() * 60);
} else {
vertical_scrollbar().set_value(vertical_scrollbar().value() + event.wheel_delta() * 20);