Windows: Fix Alt key press entering menu loop#2665
Windows: Fix Alt key press entering menu loop#2665msiglreith merged 1 commit intorust-windowing:masterfrom SamRodri:master
Conversation
|
I'm not sure about this fix, I never used the native menu thing and don't know how to create one to test it, the Also I don't understand why Windows starts a menu loop when there is no menu, I'm actually assuming that's whats happening based on Stackoverflow. |
|
Ok, I tested with a menu created like this: unsafe {
let hwnd = window.hwnd();
let menu = CreateMenu();
AppendMenuA(menu, MF_STRING, 0, b"Test".as_ptr());
SetMenu(hwnd, menu);
}It seems to get the focus. |
amrbashir
left a comment
There was a problem hiding this comment.
I am not quite familiar with the keyboard handling, but I am fine with this change and can't see an immediate regression since winit used to always return 0 for this message.
I'd better wait for @msiglreith confirmation.
|
Could you provide some more information or an example to reproduce? I can't reproduce the bug from the issue mentioned right now. Also, please add some more comments in the code why this line was added. |
|
Modify the example window to only print relevant events: #![allow(clippy::single_match)]
use simple_logger::SimpleLogger;
use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder,
};
fn main() {
SimpleLogger::new().init().unwrap();
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(&event_loop)
.unwrap();
event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
match event {
Event::WindowEvent { event, window_id } => match event {
WindowEvent::CloseRequested if window_id == window.id() => control_flow.set_exit(),
WindowEvent::KeyboardInput { input, .. } => println!("{:?}", input),
_ => {}
},
Event::MainEventsCleared => {
println!("Cleared");
window.request_redraw();
}
_ => (),
}
});
}Run it, it will not print "Cleared" after pressing and releasing Will add comments. |
CHANGELOG.mdif knowledge of this change could be valuable to usersFixes #2661 by detecting if the window has a native menu before delegating to the modal menu loop.