learn-wgpu icon indicating copy to clipboard operation
learn-wgpu copied to clipboard

new_inner_size: No such field

Open Cg1340 opened this issue 8 months ago • 1 comments

I am using winit version 0.29 and when I write the following code following the tutorial called "The Surface":

event_loop
    .run(move |event, control_flow| {
        match event {
            Event::WindowEvent {
                ref event,
                window_id,
            } if window_id == state.window().id() => {
                if !state.input(event) {
                    // UPDATED!
                    match event {
                        WindowEvent::CloseRequested
                        | WindowEvent::KeyboardInput {
                            event:
                                KeyEvent {
                                    state: ElementState::Pressed,
                                    physical_key: PhysicalKey::Code(KeyCode::Escape),
                                    ..
                                },
                            ..
                        } => control_flow.exit(),
                        WindowEvent::Resized(physical_size) => {
                            state.resize(*physical_size);
                        }
                        WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
                            state.resize(**new_inner_size);
                        }
                        _ => {}
                    }
                }
            }
            _ => {}
        }
    })
    .unwrap();

Rust gives me an error:

error[E0026]: variant `winit::event::WindowEvent::ScaleFactorChanged` does not have a field named `new_inner_size`
   --> src\lib.rs:177:63
    |
177 | ...                   WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
    |                                                         ^^^^^^^^^^^^^^ variant `winit::event::WindowEvent::ScaleFactorChanged` does not have this field

I would like to know how to deal with this problem, thanks.

Cg1340 avatar Jun 16 '24 09:06 Cg1340