imgui mouse wheel disable with glfw scroll callback function

Created on 20 Apr 2018  路  5Comments  路  Source: ocornut/imgui

Version/Branch of Dear ImGui:

1.61

Back-end/Renderer/OS:

glfw
windows 7

My Issue/Question:
the imgui mouse wheel scroll seems diable when I use glfwSetScrollCallback() function.if I comment out the glfwSetScrollCallback(),the imgui mouse wheel scroll works again.Is there a way to keep the imgui mouse wheel scroll working while maintain my scrollcallback function?

//the glfw scroll callback seems conflict with imgui mouse wheel
glfwSetScrollCallback(window, scroll_callback);
backenbinding

Most helpful comment

Hello @kingatgi,

ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks) is installing callback including a mouse wheel callback.

You can call the imgui callback yourself from your own callback:
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);

All 5 comments

Hello @kingatgi,

ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks) is installing callback including a mouse wheel callback.

You can call the imgui callback yourself from your own callback:
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);

thanks @ocornut .now it works like a charm.

I was facing the same problem as kingatgi and solved it by using your method. Thank you @ocornut !

@kingatgi @yuchenz27 I have now modified the GLFW bindings to automatically save and call user's callbacks to avoid this confusion for future users.

Just comment these lines out in the imgui_impl_glfw_gl3.cpp

static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
{
    // glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
    // glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
    // glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
    // glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
}

And then you can implement them for your self with

/// typedef GLFWwindow window_t;
///  static void mouseScrollDataGet( window_t* t_window, double_t t_xOffset, double_t t_yOffset);
glfwSetScrollCallback(window_t*, mouseScrollDataGet );
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ILoveImgui picture ILoveImgui  路  3Comments

the-lay picture the-lay  路  3Comments

KaungZawHtet picture KaungZawHtet  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

ocornut picture ocornut  路  3Comments