Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/
Other
9.36k stars 571 forks source link

Moving mouse out of Window when still holding scrollbar is treated as unactive #547

Open SAOMDVN opened 1 year ago

SAOMDVN commented 1 year ago

I have a simple Group on a Window widget. This Group has many elements which spawns a scrollbar. If I hold onto the scrollbar and move my mouse outside of the current window nk_item_is_any_active will return false even though I haven't let go of the scrollbar. The expected behaviour is the Group widget is still being active/focused.

Demonstration:

https://user-images.githubusercontent.com/34767287/221190771-16ae477b-d63b-4e9b-bcdc-758b668e1981.mp4

I'm currently using the raylib runtime at https://github.com/RobLoach/raylib-nuklear

RobLoach commented 8 months ago

Thanks! Could possibly be an issue with the raylib implementation. Mind chatting there?

RobLoach commented 7 months ago

Ah, I'm not sure this is implementation specific. Do you have any sample code to test this? Does it work in the Overview example?

SAOMDVN commented 7 months ago

You can test with this:

int main() {
    InitWindow(640, 480, "raylib-nuklear example");

    // Create the Nuklear Context
    int fontSize = 10;
    const char *activeText[2] = {"Inactive", "Active"};
    struct nk_context *ctx = InitNuklear(fontSize);

    while (!WindowShouldClose()) {
        // Update the Nuklear context, along with input
        UpdateNuklear(ctx);

        // Nuklear GUI Code
        // https://github.com/Immediate-Mode-UI/Nuklear/wiki/Window
        if (nk_begin(ctx, "Nuklear", nk_rect(100, 100, 220, 220),
                NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
            nk_layout_row_static(ctx, 50, 150, 1);
            //Random text to make the scrollbar appear
            nk_label(ctx, "Lorem Ipsum", NK_LEFT);
            nk_label(ctx, "Lorem Ipsum", NK_LEFT);
            nk_label(ctx, "Lorem Ipsum", NK_LEFT);
            nk_label(ctx, "Lorem Ipsum", NK_LEFT);
        }
        nk_end(ctx);

        // Render
        BeginDrawing();
            ClearBackground(GRAY);

            int active = nk_item_is_any_active(ctx);
            DrawText(activeText[active], 400, 200, 20, GREEN);

            // Render the Nuklear GUI
            DrawNuklear(ctx);

        EndDrawing();
    }

    // De-initialize the Nuklear GUI
    UnloadNuklear(ctx);

    CloseWindow();
    return 0;
}