Skip to content

Appending to existing menus? #1207

@degracode

Description

@degracode

Is there a way that you can extend a menu that's already been created elsewhere? Quite often it's useful for sub-systems and unconnected bits of code to expose new commands etc in the main menu bar, but at the moment each call to BeginMenu() will create a new menu, rather than extending the previous instance of it.

Effectively, I want this code:

if(ImGui::BeginMenu("Test"))
{
	ImGui::MenuItem("Test Item 1");
	ImGui::EndMenu();
}

if(ImGui::BeginMenu("Test"))
{
	ImGui::MenuItem("Test Item 2");
	ImGui::EndMenu();
}

to behave as-if I'd simply done this:

if(ImGui::BeginMenu("Test"))
{
	ImGui::MenuItem("Test Item 1");
	ImGui::MenuItem("Test Item 2");
	ImGui::EndMenu();
}

however I end up with two menus, that have aliased input, and a weird clipping issue with the second item's text:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions