Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: egui mouse check #147

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MOj0
Copy link

@MOj0 MOj0 commented Aug 15, 2023

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
Copy link
Author

MOj0 commented Aug 31, 2023

cc @jakobhellermann

@jakobhellermann
Copy link
Owner

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
Copy link
Owner

I think this would fit very nicely in bevy_egui itself, I opened an issue upstream: mvlabat/bevy_egui#218

@MOj0
Copy link
Author

MOj0 commented Oct 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants