Merge branch 'main' into return_of_the_crab
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
d56f8d7c56
1 changed files with 8 additions and 3 deletions
11
src/main.rs
11
src/main.rs
|
@ -80,14 +80,19 @@ fn main() {
|
||||||
button,
|
button,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if *button == MouseButton::Left && *mouse_state == ElementState::Pressed {
|
if !state.mouse_grabbed && *button == MouseButton::Left && *mouse_state == ElementState::Pressed {
|
||||||
let _ = window.set_cursor_grab(true);
|
let _ = window.set_cursor_grab(true);
|
||||||
window.set_cursor_visible(false);
|
window.set_cursor_visible(false);
|
||||||
state.mouse_grabbed = true;
|
state.mouse_grabbed = true;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
state.window_event(event);
|
state.window_event(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
WindowEvent::Focused(false) => {
|
||||||
|
let _ = window.set_cursor_grab(false);
|
||||||
|
window.set_cursor_visible(true);
|
||||||
|
state.mouse_grabbed = false;
|
||||||
|
}
|
||||||
event => { state.window_event(event); }
|
event => { state.window_event(event); }
|
||||||
},
|
},
|
||||||
Event::RedrawRequested(_) => {
|
Event::RedrawRequested(_) => {
|
||||||
|
|
Loading…
Reference in a new issue