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,23 +137,25 @@ 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(
window_id: WindowId(id), std::iter::once(Event::WindowEvent {
event: WindowEvent::CursorMoved { window_id: WindowId(id),
device_id: DeviceId(device::Id(pointer_id)), event: WindowEvent::CursorMoved {
position, device_id: DeviceId(device::Id(pointer_id)),
modifiers, position,
}, modifiers,
}); },
runner.send_event(Event::WindowEvent { })
window_id: WindowId(id), .chain(std::iter::once(Event::WindowEvent {
event: WindowEvent::MouseInput { window_id: WindowId(id),
device_id: DeviceId(device::Id(pointer_id)), event: WindowEvent::MouseInput {
state: ElementState::Pressed, device_id: DeviceId(device::Id(pointer_id)),
button, state: ElementState::Pressed,
modifiers, button,
}, modifiers,
}); },
})),
);
}); });
let runner = self.runner.clone(); let runner = self.runner.clone();