Fix awkward mouse conflict issues between egui and the engine
This commit is contained in:
parent
f5a16213fa
commit
8041c7e01d
6 changed files with 53 additions and 4 deletions
|
|
@ -106,6 +106,11 @@ impl System for MainSystem {
|
|||
character_pos = tr.translation;
|
||||
}
|
||||
egui_queue.queue(move |egui_ctx| {
|
||||
// disable text selection on all labels.
|
||||
egui_ctx.style_mut(|style| {
|
||||
style.interaction.selectable_labels = false;
|
||||
});
|
||||
|
||||
egui::Window::new("Debug").show(egui_ctx, |ui| {
|
||||
ui.label("Hello World!");
|
||||
ui.label(format!("Frame Delta: {:.3}", time_ctx.frame_dt));
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ impl System for MenuSystem {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
fn handle_event(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
// The menu is toggled by pressing the escape key
|
||||
let input = res.get::<InputState>().unwrap();
|
||||
|
|
@ -63,18 +64,21 @@ impl MenuSystem {
|
|||
.next()
|
||||
.unwrap();
|
||||
|
||||
let window = res.get::<PlatformContext>().unwrap().window.lock().unwrap();
|
||||
let pctx = res.get::<PlatformContext>().unwrap();
|
||||
let window = pctx.window.lock().unwrap();
|
||||
|
||||
match *menu_state {
|
||||
MenuState::Open => {
|
||||
*menu_state = MenuState::Closed;
|
||||
window.set_cursor_grab(CursorGrabMode::Confined).or_else(|_| window.set_cursor_grab(CursorGrabMode::Locked));
|
||||
window.set_cursor_visible(false);
|
||||
pctx.should_egui_receive_input_events.set(false);
|
||||
},
|
||||
MenuState::Closed => {
|
||||
*menu_state = MenuState::Open;
|
||||
window.set_cursor_grab(CursorGrabMode::None);
|
||||
window.set_cursor_visible(true);
|
||||
pctx.should_egui_receive_input_events.set(true);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue