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

Don't CaptureMouseFromApp() #533

Closed
dkrikun opened this issue Feb 22, 2016 · 9 comments
Closed

Don't CaptureMouseFromApp() #533

dkrikun opened this issue Feb 22, 2016 · 9 comments

Comments

@dkrikun
Copy link

dkrikun commented Feb 22, 2016

I have a small scene to render inside imgui window. So I am rendering it to a texture and then displaying it in an image (as you've recommended in #530), and everything works great.

The problem is, I would like imgui NOT to handle mouse events when the focus is inside my image.
But CaptureMouseFromApp() only allows to force capture the input.

@nem0
Copy link
Contributor

nem0 commented Feb 22, 2016

Does #532 help?

@ocornut
Copy link
Owner

ocornut commented Feb 22, 2016

What does "NOT to handle mouse events" means?
Do you want to prevent the window from being moved?
If you want just want your application to use mouse inputs, then just ignore the WantCaptureMouse flag.

@dkrikun
Copy link
Author

dkrikun commented Feb 22, 2016

You say in #532:

You can check io.WantCaptureKeyboard after calling ImGui::Update() and hide the inputs from the rest of your app when true.

I would like to achieve exactly the opposite: to hide the inputs from ImGui. Ok, you could say, I have the control over the ImGui::GetIO() etc., but this is global.

Yeah, I would like to prevent the window from moving and scrolling, and instead let the "inner" scene to handle mouse events.

@ocornut
Copy link
Owner

ocornut commented Feb 22, 2016

You don't need to hide the input from ImGui, you need your application to read the inputs.
Clicking an Image() shouldn't move the window. You can disable mouse wheel scrolling with a flag in Begin or BeginChild.

Just test for IsItemHovered(), set your own flag and test this flag in your code that checks WantCapture* flags to accept the inputs when set.

@dkrikun
Copy link
Author

dkrikun commented Feb 22, 2016

I think it does move the window, I'll check it.

@dkrikun
Copy link
Author

dkrikun commented Feb 23, 2016

Dragging the image moves the window that contains it

@ocornut
Copy link
Owner

ocornut commented Feb 23, 2016

Use ImageButton()

ocornut added a commit that referenced this issue Mar 2, 2016
…earing the capture flag (#533) + demo + made code a little less messy
@ocornut
Copy link
Owner

ocornut commented Mar 2, 2016

@dkrikun I have added a bool parameter to CaptureKeyboardFromApp() and CaptureKeyboardFromApp() so that may be used to easily communicate the information down to the main code.

The demo code does:

            ImGui::Button("Holding me clears the\nthe keyboard capture flag");
            if (ImGui::IsItemActive())
                ImGui::CaptureKeyboardFromApp(false);

I also tested that you can use ImageButton() or InvisibleButton() to prevent moving the window. Let me know if that works for you!

@ocornut ocornut closed this as completed Mar 2, 2016
@dkrikun
Copy link
Author

dkrikun commented Mar 9, 2016

Thanks :)

ocornut added a commit that referenced this issue Nov 1, 2017
ocornut added a commit that referenced this issue May 23, 2022
…FrameWantCaptureMouse() and SetNextFrameWantCaptureKeyboard(). Added demo. (#5304, #4831, #4480, #533)
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