Use send_events instead of send_event in web backend (#1681)

This commit is contained in:
alvinhochun 2020-08-27 00:11:27 +08:00 committed by GitHub
parent 0f7c82d38f
commit bea60930b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,15 +137,16 @@ impl<T> WindowTarget<T> {
// A mouse down event may come in without any prior CursorMoved events, // A mouse down event may come in without any prior CursorMoved events,
// therefore we should send a CursorMoved event to make sure that the // therefore we should send a CursorMoved event to make sure that the
// user code has the correct cursor position. // user code has the correct cursor position.
runner.send_event(Event::WindowEvent { runner.send_events(
std::iter::once(Event::WindowEvent {
window_id: WindowId(id), window_id: WindowId(id),
event: WindowEvent::CursorMoved { event: WindowEvent::CursorMoved {
device_id: DeviceId(device::Id(pointer_id)), device_id: DeviceId(device::Id(pointer_id)),
position, position,
modifiers, modifiers,
}, },
}); })
runner.send_event(Event::WindowEvent { .chain(std::iter::once(Event::WindowEvent {
window_id: WindowId(id), window_id: WindowId(id),
event: WindowEvent::MouseInput { event: WindowEvent::MouseInput {
device_id: DeviceId(device::Id(pointer_id)), device_id: DeviceId(device::Id(pointer_id)),
@ -153,7 +154,8 @@ impl<T> WindowTarget<T> {
button, button,
modifiers, modifiers,
}, },
}); })),
);
}); });
let runner = self.runner.clone(); let runner = self.runner.clone();