mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Force ungrab on Key::ToggleCursor
Former-commit-id: 222f5693363662d25cb065fdc104cd079e2c395d
This commit is contained in:
parent
0e46b00a0c
commit
e8cf815143
@ -201,6 +201,7 @@ pub struct Hud {
|
||||
show: Show,
|
||||
to_focus: Option<Option<widget::Id>>,
|
||||
settings: Settings,
|
||||
force_ungrab: bool,
|
||||
}
|
||||
|
||||
impl Hud {
|
||||
@ -236,6 +237,7 @@ impl Hud {
|
||||
},
|
||||
to_focus: None,
|
||||
settings,
|
||||
force_ungrab: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,6 +522,13 @@ impl Hud {
|
||||
self.show.toggle_help();
|
||||
true
|
||||
}
|
||||
Key::ToggleCursor => {
|
||||
self.force_ungrab = !self.force_ungrab;
|
||||
if self.force_ungrab {
|
||||
global_state.window.grab_cursor(false);
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {
|
||||
@ -534,8 +543,10 @@ impl Hud {
|
||||
_ => false,
|
||||
};
|
||||
// Handle cursor grab
|
||||
if let Some(state) = self.show.want_grab.take() {
|
||||
global_state.window.grab_cursor(state);
|
||||
if !self.force_ungrab {
|
||||
if let Some(state) = self.show.want_grab.take() {
|
||||
global_state.window.grab_cursor(state);
|
||||
}
|
||||
}
|
||||
|
||||
handled
|
||||
|
@ -127,12 +127,6 @@ impl PlayState for SessionState {
|
||||
Event::Close => {
|
||||
return PlayStateResult::Shutdown;
|
||||
}
|
||||
// Toggle cursor grabbing
|
||||
Event::KeyDown(Key::ToggleCursor) => {
|
||||
global_state
|
||||
.window
|
||||
.grab_cursor(!global_state.window.is_cursor_grabbed());
|
||||
}
|
||||
// Movement Key Pressed
|
||||
Event::KeyDown(Key::MoveForward) => self.key_state.up = true,
|
||||
Event::KeyDown(Key::MoveBack) => self.key_state.down = true,
|
||||
|
Loading…
Reference in New Issue
Block a user