-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: Fix Alt key press entering menu loop #2665
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
CHANGELOG.md
if 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.