Skip to content

GLFW Callbacks after ImGui initialization #4981

@cajallen

Description

@cajallen

Version/Branch of Dear ImGui:

Version: 1.87 WIP (18608)
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

My Issue/Question:
How are custom callbacks supposed to be set with GLFW post ImGui initialization? I would prefer to allow ImGui to install it's callbacks and not have to worry about calling them in my own code, which seems to be supported outside of this case.

Screenshots/Video
None

Standalone, minimal, complete and verifiable example:

int main () {
    // Window Creation... etc...
    glfwSetKeyCallback(window, my_key_callback);
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO();
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
    ImGui_ImplGlfw_InitForOpenGL(window, true); 
    // At this point,  ImGui_ImplGlfw_GetBackendData()->PrevUserCallbackKey is my_key_callback
    ImGui_ImplOpenGL3_Init("#version 450");
    
    glfwSetKeyCallback(window, my_new_key_callback);
    // How to set state so that GLFW key callback is ImGui's, and 
    // ImGui_ImplGlfw_GetBackendData()->PrevUserCallbackKey is my_key_callback?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions