To the best of my knowledge (which admittedly is not much), the current way that winit does event_loop processing doesn't provide an &Event<_> that can be sent to winit::platform::handle_event. Therefore, I can't implement step 3 in the 5 steps that have to be completed...
"3. Pass events to the platform (every frame) with [WinitPlatform::handle_event]."
Edit:
Ok...so after posting this, I came up with a solution to my issue. winit::platform::handle_event just takes the enum Event value and looks for a WindowEvent, which it then passes on to a private function handle_window_event.
So I solved my issue with the following code, located at the end of the match statement in the winit::ApplicationHandler function window_event: (gui.platform is my variable for a WinitPlatform)
_ => {
let generic_event: winit::event::Event = winit::event::Event::WindowEvent {
window_id,
event,
};
gui.platform.handle_event(gui.imgui.io_mut(), &window, &generic_event);
window.request_redraw();
},
And this works.
So two possible fixes to this issue (if it's deemed an issue) would be:
- change the example code to reflect the fact that the generic_event needs to be created explicitly
- make WinitPlatform::handle_window_event public so that the event can be passed straight through
Edit #2:
I see now that this issue is exactly what the only open pull request is looking to achieve...sorry about that, I'm still learning!
To the best of my knowledge (which admittedly is not much), the current way that winit does event_loop processing doesn't provide an &Event<_> that can be sent to winit::platform::handle_event. Therefore, I can't implement step 3 in the 5 steps that have to be completed...
"3. Pass events to the platform (every frame) with [WinitPlatform::handle_event]."
Edit:
Ok...so after posting this, I came up with a solution to my issue. winit::platform::handle_event just takes the enum Event value and looks for a WindowEvent, which it then passes on to a private function handle_window_event.
So I solved my issue with the following code, located at the end of the match statement in the winit::ApplicationHandler function window_event: (gui.platform is my variable for a WinitPlatform)
_ => {
let generic_event: winit::event::Event = winit::event::Event::WindowEvent {
window_id,
event,
};
gui.platform.handle_event(gui.imgui.io_mut(), &window, &generic_event);
window.request_redraw();
},
And this works.
So two possible fixes to this issue (if it's deemed an issue) would be:
Edit #2:
I see now that this issue is exactly what the only open pull request is looking to achieve...sorry about that, I'm still learning!