Imgui: GLFW3 Scrolling registered, but not applied

Created on 25 Jun 2018  路  3Comments  路  Source: ocornut/imgui

Version/Branch of Dear ImGui:

// dear imgui, v1.62 WIP

Back-end file/Renderer/OS:

Windows 7 with GLFW and OpenGL 4.

I was using custom GLFW callbacks (which did the exact same thing as the imgui_impl_glfw_gl3 callback). However, I tried installing the callbacks in your implementation, and the issue persists on both the demo ImGui container and my own custom.

My Issue/Question:

My issue is this: the GuiIO object is clearly receiving my scroll inputs. On checking a breakpoint as well as checking via the demo window, io.MouseWheel corresponds to my scroll wheel. However, the window does not scroll. The demo window is 100% vanilla. I also tested this on a window with its flags zeroed out.

This is my scroll callback:

void GLFW_Scroll_Callback(GLFWwindow* window, double xoffset, double yoffset) {
    global_input.scroll = glm::vec2((float)xoffset, (float)yoffset);
    ImGuiIO& io = ImGui::GetIO();
    io.MouseWheelH += (float)xoffset;
    io.MouseWheel += (float)yoffset;
}

Screenshots/Video _(you can drag files here)_
imgui_no_scroll

backenbinding

Most helpful comment

The MouseWheel inputs are processed by ImGui::NewFrame() and cleared by ImGui::EndFrame();. Perhaps your code is mistakenly passing mouse wheel inputs _after_ the call to NewFrame ?

The Demo window will display the field at the time it is called but if the field wasn't set at the time of NewFrame() your input won't be processed.

You may add a breakpoint in NewFrame() and see if you ever hit that.

    // Mouse wheel scrolling, scale
    if (g.IO.MouseWheel != 0.0f && g.IO.KeyShift)
        printf(""); // BREAKPOINT HERE

image

All 3 comments

The MouseWheel inputs are processed by ImGui::NewFrame() and cleared by ImGui::EndFrame();. Perhaps your code is mistakenly passing mouse wheel inputs _after_ the call to NewFrame ?

The Demo window will display the field at the time it is called but if the field wasn't set at the time of NewFrame() your input won't be processed.

You may add a breakpoint in NewFrame() and see if you ever hit that.

    // Mouse wheel scrolling, scale
    if (g.IO.MouseWheel != 0.0f && g.IO.KeyShift)
        printf(""); // BREAKPOINT HERE

image

This worked like a charm. Thanks very much for the excellent documentation, library, and support!

Perhaps your code is mistakenly passing mouse wheel inputs after the call to NewFrame ?

I was having the same problem but with SDL2 (doesn't really matter). Mouse wheel scrolling broke at some point, and this was the fastest fix ever :smile:. Thanks @ocornut!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bizehao picture bizehao  路  3Comments

dowit picture dowit  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

KaungZawHtet picture KaungZawHtet  路  3Comments

CesaragsUC picture CesaragsUC  路  3Comments