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,
|
show: Show,
|
||||||
to_focus: Option<Option<widget::Id>>,
|
to_focus: Option<Option<widget::Id>>,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
|
force_ungrab: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hud {
|
impl Hud {
|
||||||
@ -236,6 +237,7 @@ impl Hud {
|
|||||||
},
|
},
|
||||||
to_focus: None,
|
to_focus: None,
|
||||||
settings,
|
settings,
|
||||||
|
force_ungrab: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +522,13 @@ impl Hud {
|
|||||||
self.show.toggle_help();
|
self.show.toggle_help();
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
Key::ToggleCursor => {
|
||||||
|
self.force_ungrab = !self.force_ungrab;
|
||||||
|
if self.force_ungrab {
|
||||||
|
global_state.window.grab_cursor(false);
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {
|
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {
|
||||||
@ -534,8 +543,10 @@ impl Hud {
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
// Handle cursor grab
|
// Handle cursor grab
|
||||||
if let Some(state) = self.show.want_grab.take() {
|
if !self.force_ungrab {
|
||||||
global_state.window.grab_cursor(state);
|
if let Some(state) = self.show.want_grab.take() {
|
||||||
|
global_state.window.grab_cursor(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handled
|
handled
|
||||||
|
@ -127,12 +127,6 @@ impl PlayState for SessionState {
|
|||||||
Event::Close => {
|
Event::Close => {
|
||||||
return PlayStateResult::Shutdown;
|
return PlayStateResult::Shutdown;
|
||||||
}
|
}
|
||||||
// Toggle cursor grabbing
|
|
||||||
Event::KeyDown(Key::ToggleCursor) => {
|
|
||||||
global_state
|
|
||||||
.window
|
|
||||||
.grab_cursor(!global_state.window.is_cursor_grabbed());
|
|
||||||
}
|
|
||||||
// Movement Key Pressed
|
// Movement Key Pressed
|
||||||
Event::KeyDown(Key::MoveForward) => self.key_state.up = true,
|
Event::KeyDown(Key::MoveForward) => self.key_state.up = true,
|
||||||
Event::KeyDown(Key::MoveBack) => self.key_state.down = true,
|
Event::KeyDown(Key::MoveBack) => self.key_state.down = true,
|
||||||
|
Loading…
Reference in New Issue
Block a user