Git Product home page Git Product logo

Comments (5)

ocornut avatar ocornut commented on May 13, 2024 22

Mattias: I suspect that your underlying question is that you'd like to know when to pass your inputs to ImGui, i am right ?

In the IO structure you can find:
bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)

This is updated by NewFrame() so the idea is that you pass your raw inputs to ImGui but it doesn't necessary use them. If the flag aren't set you can pass the inputs back to the rest of your application.

Now, through various feedbacks it appears that this was confusing to some engine architecture, e.g. if you are trying to dispatch inputs events directly to the right target. My suggestion would be to just store data and pass it to ImGui before NewFrame().

You can set io.MousePos and call ImGui::IsMouseHoveringAnyWindow() to test if a position is over a window. Detect if a widget has focus for keyboard is IO.WantCaptureKeyboard.

I think I need to revamp those API to be a little more clear. Perhaps adding an explicit WidgetHasFocus thing?

from imgui.

xythobuz avatar xythobuz commented on May 13, 2024

Additionally, I would really like a way to give keyboard focus to a specific text field...

from imgui.

ocornut avatar ocornut commented on May 13, 2024

xythobuz: separate issue/thread please.

from imgui.

mattiasljungstrom avatar mattiasljungstrom commented on May 13, 2024

Yes, thanks for the information! This setup sounds good to me, since I just need to know when to block input to my code.

from imgui.

Bonkt avatar Bonkt commented on May 13, 2024

I want to do something similar to this. (using sfml) i render my main application to a sf::RenderTexture that i then display on ImGui::Image(). So basically my dockspace and my whole window is at all times completely covered by ImGui windows.

So when i try to dispatch mouse clicks to my application i want to check if io.WantCaptureMouse.
The problem is that i also want to be able to move my "application" window around. So setting the flag ImGuiWindowFlags_NoMouseInputs does not work.

I read at many places that io.WantCaptureMouse is prefered over IsWindowHovered().
Is this still the case for my use case? Or would a new flag with a name like
ImGuiWindowFlags_OnlyMouseInputsOnTitlebar be a useful addition to the API?

Edit:
Basically i want to create something similiar looking to the "Canvas" demo. But instead of rendering the canvas in ImGui i want to render in SFML to a texture and then display that on a ImGui windows.

@ocornut

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.