WindowBuilderExtWebSys::with_prevent_default disables scrolling on both mobile and desktop (previously just desktop) (#2216)

* Disable scrolling on web by default but provide method in builder to enable it

* rename enable_web_scroll -> enable_web_page_scroll

* move enable_web_page_scroll into prevent_default option

* final approach

* Mark prevent_default change as breaking

Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
Lucas Kent 2022-09-04 13:45:30 +10:00 committed by GitHub
parent ab56e9f57d
commit 0fca8b088d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 19 deletions

View file

@ -63,6 +63,9 @@ impl<T> EventLoopWindowTarget<T> {
let mut canvas = canvas.borrow_mut();
canvas.set_attribute("data-raw-handle", &id.0.to_string());
canvas.on_touch_start(prevent_default);
canvas.on_touch_end(prevent_default);
let runner = self.runner.clone();
canvas.on_blur(move || {
runner.send_event(Event::WindowEvent {
@ -153,22 +156,25 @@ impl<T> EventLoopWindowTarget<T> {
});
let runner = self.runner.clone();
canvas.on_cursor_move(move |pointer_id, position, delta, modifiers| {
runner.send_event(Event::WindowEvent {
window_id: RootWindowId(id),
event: WindowEvent::CursorMoved {
canvas.on_cursor_move(
move |pointer_id, position, delta, modifiers| {
runner.send_event(Event::WindowEvent {
window_id: RootWindowId(id),
event: WindowEvent::CursorMoved {
device_id: RootDeviceId(DeviceId(pointer_id)),
position,
modifiers,
},
});
runner.send_event(Event::DeviceEvent {
device_id: RootDeviceId(DeviceId(pointer_id)),
position,
modifiers,
},
});
runner.send_event(Event::DeviceEvent {
device_id: RootDeviceId(DeviceId(pointer_id)),
event: DeviceEvent::MouseMotion {
delta: (delta.x, delta.y),
},
});
});
event: DeviceEvent::MouseMotion {
delta: (delta.x, delta.y),
},
});
},
prevent_default,
);
let runner = self.runner.clone();
canvas.on_mouse_press(move |pointer_id, position, button, modifiers| {