Skip to content

Commit

Permalink
Update bevy_egui to 0.29. Fix egui input filtering. (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
hammypants authored Nov 11, 2024
1 parent ea2e3f4 commit 3c701c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ impl Plugin for AccumulatorPlugin {
PreUpdate,
InputManagerSystem::Accumulate
.after(InputSystem)
.before(InputManagerSystem::Filter)
.before(InputManagerSystem::Unify),
);
}
Expand Down
8 changes: 6 additions & 2 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ pub fn filter_captured_input(
bevy::input::ButtonInput<bevy::input::keyboard::KeyCode>,
>,
#[cfg(feature = "egui")] mut egui_query: Query<&'static mut bevy_egui::EguiContext>,
#[cfg(feature = "egui")] mut mouse_scroll: ResMut<AccumulatedMouseScroll>,
#[cfg(feature = "egui")] mut mouse_motion: ResMut<AccumulatedMouseMovement>,
) {
// If the user clicks on a button, do not apply it to the game state
#[cfg(feature = "ui")]
Expand All @@ -154,11 +156,13 @@ pub fn filter_captured_input(
for mut egui_context in egui_query.iter_mut() {
// Don't ask me why get doesn't exist :shrug:
if egui_context.get_mut().wants_pointer_input() {
mouse_buttons.clear();
mouse_buttons.reset_all();
mouse_motion.reset();
mouse_scroll.reset();
}

if egui_context.get_mut().wants_keyboard_input() {
keycodes.clear();
keycodes.reset_all();
}
}
}
Expand Down

0 comments on commit 3c701c3

Please sign in to comment.