Skip to content

Commit

Permalink
Use send_events instead of send_event in web backend (rust-windowing#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinhochun committed Aug 26, 2020
1 parent 0f7c82d commit bea6093
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/platform_impl/web/event_loop/window_target.rs
Expand Up @@ -137,23 +137,25 @@ impl<T> WindowTarget<T> {
// A mouse down event may come in without any prior CursorMoved events,
// therefore we should send a CursorMoved event to make sure that the
// user code has the correct cursor position.
runner.send_event(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::CursorMoved {
device_id: DeviceId(device::Id(pointer_id)),
position,
modifiers,
},
});
runner.send_event(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::MouseInput {
device_id: DeviceId(device::Id(pointer_id)),
state: ElementState::Pressed,
button,
modifiers,
},
});
runner.send_events(
std::iter::once(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::CursorMoved {
device_id: DeviceId(device::Id(pointer_id)),
position,
modifiers,
},
})
.chain(std::iter::once(Event::WindowEvent {
window_id: WindowId(id),
event: WindowEvent::MouseInput {
device_id: DeviceId(device::Id(pointer_id)),
state: ElementState::Pressed,
button,
modifiers,
},
})),
);
});

let runner = self.runner.clone();
Expand Down

0 comments on commit bea6093

Please sign in to comment.