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

Events not working with multiple Nuklear windows #626

Open
lautriva opened this issue Mar 30, 2024 · 0 comments
Open

Events not working with multiple Nuklear windows #626

lautriva opened this issue Mar 30, 2024 · 0 comments

Comments

@lautriva
Copy link
Contributor

Hi, I have a problem with multiple Nuklear windows
When I add another window, the events on the first one are not handled correctly anymore
For example, hovers only work when I also left-click and mouse scroll not work

Everything work when I use only one window

Here is in pseudo-code how its done:

update_gui_events()
{
    nk_input_begin(context);
    
    // ...
    // Calls to nk_input_*** to send inputs to Nuklear based on the current state
    // I'm using NK_KEYSTATE_BASED_INPUT
    // ...
    
    nk_input_end(context);
}

generate_gui()
{
    if (nk_begin_titled(context, "win1", ...)
    {
        // ... Window 1 content
    }
    nk_end(context);
    
    if (nk_begin_titled(context, "win2", ...)
    {
        // ... Window 2 content
    }
    nk_end(context);

    // Hack
    // If I uncomment this line, the hover events seems to work on both windows
    //     but the scroll problem is still present
    // nk_window_set_focus(context, "win1");
}

render_gui()
{
    // ...
    // Engine specific calls to init the render
    // ...

    nk_buffer_init_fixed(&vertices, ...);
    nk_buffer_init_fixed(&elements, ...);
    nk_convert(ctx, command_buffer, &vertices, &elements, ...);

    nk_draw_foreach(cmd, ctx, command_buffer)
    {
        // ...
        // Engine specific calls to draw the vertices
        // ...
    }

    nk_clear(ctx);
    nk_buffer_free(&vertices);
    nk_buffer_free(&elements);
    
    // ...
    // Engine specific calls to end the render
    // ...
}

Then on each frame

update_gui_events()
generate_gui()
render_gui();
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

1 participant