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

Is there any way to prevent click events on ImGui from falling into SFML? #24

Closed
DEAGS3000 opened this issue Mar 8, 2017 · 4 comments
Closed

Comments

@DEAGS3000
Copy link

As the title, do ImGui or SFML have this function? Or I need to implement that by my self?

@DEAGS3000 DEAGS3000 changed the title Is there any way to prevent click events on ImGui fall into SFML? Is there any way to prevent click events on ImGui from falling into SFML? Mar 8, 2017
@ghost
Copy link

ghost commented Mar 8, 2017

To my knowledge, there's no way of doing this automatically. You could potentially use ImGui::IsAnyItemHovered() or ImGui::IsAnyItemActive() (or perhaps a mixture of the two) to check.

@eliasdaler
Copy link
Contributor

Yep, that's what I wanted to propose. To do so automatically would mean that I'd have to modify SFML's event queue which is not possible because of SFML's interface.

@Julzso23
Copy link

Julzso23 commented Oct 4, 2018

I recently solved this issue in my game by checking ImGuiIO::WantCaptureMouse and ImGuiIO::WantCaptureKeyboard before handling my mouse and keyboard events.

For example:

ImGuiIO& io = ImGui::GetIO();
switch (event.type)
{
    case sf::Event::MouseButtonReleased:
    {
        if (io.WantCaptureMouse) break;
        break;
    }
}

@eliasdaler
Copy link
Contributor

More info:

From ImGui:

You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
- When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
- When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.

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

No branches or pull requests

3 participants