mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Ladybird/AppKit: Add mouse wheel events
This commit is contained in:
parent
f6c52f622d
commit
69482f1f14
Notes:
sideshowbarker
2024-07-17 08:34:29 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/69482f1f14 Pull-request: https://github.com/SerenityOS/serenity/pull/21124 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 18 additions and 0 deletions
|
@ -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];
|
||||
|
|
|
@ -100,6 +100,11 @@ void WebViewBridge::set_preferred_color_scheme(Web::CSS::PreferredColorScheme co
|
|||
client().async_set_preferred_color_scheme(color_scheme);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_wheel_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers, int wheel_delta_x, int wheel_delta_y)
|
||||
{
|
||||
client().async_mouse_wheel(to_content_position(position), screen_position, to_underlying(button), to_underlying(button), modifiers, wheel_delta_x, wheel_delta_y);
|
||||
}
|
||||
|
||||
void WebViewBridge::mouse_down_event(Gfx::IntPoint position, Gfx::IntPoint screen_position, GUI::MouseButton button, KeyModifier modifiers)
|
||||
{
|
||||
client().async_mouse_down(to_content_position(position), screen_position, to_underlying(button), to_underlying(button), modifiers);
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
void update_palette();
|
||||
void set_preferred_color_scheme(Web::CSS::PreferredColorScheme);
|
||||
|
||||
void mouse_wheel_event(Gfx::IntPoint, Gfx::IntPoint, GUI::MouseButton, KeyModifier, int, int);
|
||||
void mouse_down_event(Gfx::IntPoint, Gfx::IntPoint, GUI::MouseButton, KeyModifier);
|
||||
void mouse_up_event(Gfx::IntPoint, Gfx::IntPoint, GUI::MouseButton, KeyModifier);
|
||||
void mouse_move_event(Gfx::IntPoint, Gfx::IntPoint, GUI::MouseButton, KeyModifier);
|
||||
|
|
Loading…
Reference in a new issue