Don't send egui events when it is hidden and as a result these events are also never captured by egui. This fixes issues with the mouse clicks being captured if the mouse was hovered over the egui UI when it was toggled off.

This commit is contained in:
Imbris 2022-01-25 01:23:38 -05:00
parent 54d5a06a0d
commit 2bada7f02a

View File

@ -33,9 +33,15 @@ pub fn run(mut global_state: GlobalState, event_loop: EventLoop) {
#[cfg(feature = "egui-ui")]
{
global_state.egui_state.platform.handle_event(&event);
if global_state.egui_state.platform.captures_event(&event) {
return;
let enabled_for_current_state =
states.last().map_or(false, |state| state.egui_enabled());
// Only send events to the egui UI when it is being displayed.
if enabled_for_current_state && global_state.settings.interface.egui_enabled() {
global_state.egui_state.platform.handle_event(&event);
if global_state.egui_state.platform.captures_event(&event) {
return;
}
}
}