[Glium] Window Events not processed correctly

I've been messing around with Glium, and can't seem to process window events correctly. Clicking the 'X' in the window seems to freeze the process (the frame isn't drawn, or any calculations processed while held), rather than closing the window. I'm also trying to process keyboard inputs, but the event loop doesn't seem to recognize them either. Event handling loop is below:

 // Event Handling
        match event {
            glutin::event::Event::WindowEvent { event, .. } => match event {
                glutin::event::WindowEvent::CloseRequested => {
                    *control_flow = glutin::event_loop::ControlFlow::Exit;

                glutin::event::WindowEvent::KeyboardInput {
                    glutin::event::KeyboardInput {
                        virtual_keycode: Some(VirtualKeyCode::Left),
                } => println!("LEFT"),

                _ => return,
            glutin::event::Event::NewEvents(cause) => match cause {
                glutin::event::StartCause::ResumeTimeReached { .. } => (),
                glutin::event::StartCause::Init => (),
                _ => return,
            _ => return,

glium version is 0.31.0, OS is Win11, if that helps.

Any help would be appreciated, thanks!

I'm dumb, sorry guys. I had a bunch of the glium structs set up in a seperate GUI struct, which was built with a seperate event loop declaration lol. It wasn't connected because the real linked event loop was out-of-scope. Whoops

1 Like

Don't beat yourself up over it - there's a well-known effect where the fact of writing out your situation, what you've tried, and what's not working is enough to break you out of "tunnel vision" while debugging.

Your write-up was detailed, and you made a good effort to tell us about environment issues that might affect it (OS, versions). About the only thing that could possibly have been better (and might have caused you to identify the problem before posting) is if you were able to reduce the problem to a small example that we could easily compile and run ourselves - I suspect that, in the process of removing "unnecessary" detail from your real project, you'd have run across the second event loop, and been unable to remove it.

Sounds like that's what happened here - you wrote out the problem in detail, which triggered you into thinking about the bits you didn't write out, and thus pointed you at the underlying problem.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.