Skip to content

How to check/uncheck Menu Items without closing a Menu #1379

Closed
@Flix01

Description

I've quickly found an easy way to do it:

            // Just a test to check/uncheck multiple checkItems without closing the Menu (with the RMB)
            static bool booleanProps[3]={true,false,true};
            static const char* names[3]={"Boolean Test 1","Boolean Test 2","Boolean Test 3"};
            const bool isRightMouseButtonClicked = ImGui::IsMouseClicked(1);    // cached
            for (int i=0;i<3;i++)   {
                ImGui::MenuItem(names[i], NULL, &booleanProps[i]);
                if (isRightMouseButtonClicked && ImGui::IsItemHovered()) booleanProps[i]=!booleanProps[i];
            }

... just in case someone is interested...

@ocornut: you can close this issue at any time, since I've solved it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    menusmenu bars, menu items

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions