1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

Ladybird/AppKit: Add mouse wheel events

This commit is contained in:
Bastiaan van der Plaat 2023-09-19 20:45:01 +02:00 committed by Andreas Kling
parent f6c52f622d
commit 69482f1f14
3 changed files with 18 additions and 0 deletions

View file

@ -987,6 +987,18 @@ static void copy_text_to_clipboard(StringView text)
m_web_view_bridge->mouse_move_event(position, screen_position, button, modifiers);
}
- (void)scrollWheel:(NSEvent*)event
{
auto [position, screen_position, button, modifiers] = Ladybird::ns_event_to_mouse_event(event, self, GUI::MouseButton::Middle);
CGFloat delta_x = [event scrollingDeltaX];
CGFloat delta_y = -[event scrollingDeltaY];
if (![event hasPreciseScrollingDeltas]) {
delta_x *= [self scrollView].horizontalLineScroll;
delta_y *= [self scrollView].verticalLineScroll;
}
m_web_view_bridge->mouse_wheel_event(position, screen_position, button, modifiers, delta_x, delta_y);
}
- (void)mouseDown:(NSEvent*)event
{
[[self window] makeFirstResponder:self];