bevy-inspector-egui icon indicating copy to clipboard operation
bevy-inspector-egui copied to clipboard

Feat: egui mouse check

Open MOj0 opened this issue 2 years ago • 4 comments

Added a resource which tracks wether mouse pointer should be handled the egui or Bevy's running systems. This gets rid of annoyance where one drags the egui window around (or scrolls through it) and that input is picked up by the Bevy's systems as a normal user input.

This could potentially be in Bevy's common input conditions, however it is not really common since it only occurrs when integrating with other Plugins.

Although this is simply a difference of how the inspector is integrated, I still put it under the quick examples, since it is strictly an upgrade from World Inspector example and is not really on the level of other integrations examples.

Only works for primary window.

MOj0 avatar Aug 15 '23 16:08 MOj0

cc @jakobhellermann

MOj0 avatar Aug 31 '23 18:08 MOj0

Thanks for the PR and sorry for leaving this unread for so long.

Is there a reason this should be a Plugin instead of having the run condition directly ask the EguiContext like

fn egui_mouse_free(egui_contexts: Query<&EguiContext>) -> bool {
    egui_contexts
        .iter()
        .all(|ctx| !ctx.get().wants_pointer_input())
}
// or
fn egui_mouse_free<W: Component>(egui_contexts: Query<&EguiContext, With<W>>) -> bool {
    let ctx = egui_contexts.single().get();
    !ctx.wants_pointer_input()
}

?

I'd like to keep the amount of boilerplate required as minimal as possible.

jakobhellermann avatar Oct 10 '23 15:10 jakobhellermann

I think this would fit very nicely in bevy_egui itself, I opened an issue upstream: https://github.com/mvlabat/bevy_egui/issues/218

jakobhellermann avatar Oct 10 '23 15:10 jakobhellermann

Thanks for the PR and sorry for leaving this unread for so long.

Is there a reason this should be a Plugin instead of having the run condition directly ask the EguiContext like

fn egui_mouse_free(egui_contexts: Query<&EguiContext>) -> bool {
    egui_contexts
        .iter()
        .all(|ctx| !ctx.get().wants_pointer_input())
}
// or
fn egui_mouse_free<W: Component>(egui_contexts: Query<&EguiContext, With<W>>) -> bool {
    let ctx = egui_contexts.single().get();
    !ctx.wants_pointer_input()
}

?

I'd like to keep the amount of boilerplate required as minimal as possible.

There is no real reason as to why this should be a Plugin. I only did it because I thought it is cleaner that way, but then again I'm somewhat new to bevy. Doing it with just a function is indeed less boilerplate, so let's do it that way.

MOj0 avatar Oct 10 '23 18:10 MOj0