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

Combo Box does not work with Modal (or any) Popups #1865

Closed
wrinch opened this issue Jun 6, 2018 · 2 comments
Closed

Combo Box does not work with Modal (or any) Popups #1865

wrinch opened this issue Jun 6, 2018 · 2 comments
Labels

Comments

@wrinch
Copy link

wrinch commented Jun 6, 2018

ImGui Version: v1.61
Backend: DirectX11 sample (as well as our own DirectX12)

It seems if I create a popup (modal or otherwise) I cannot use a combo box in the popup. Clicking the down arrow on the combo box flickers for a frame and then disappears. This works just fine with a regular window.

Thanks so much for writing ImGui by the way! It's great! I'm going to get our company to send you a donation here soon, as looks like we will be using ImGui more and more.

Cheers,

-Steve

ImGui::OpenPopup("BrokenComboBoxes");
if (ImGui::BeginPopupModal("BrokenComboBoxes", nullptr, 0)) {
	static int loggingLevel = 0;
	static const char* logLevels[] = {
		"Trace",
		"Debug",
		"Info",
		"Warn",
		"Error",
		"Critical"
	};
	ImGui::Combo("Logging Level", &loggingLevel, logLevels, IM_ARRAYSIZE(logLevels));
}
ImGui::EndPopup();

brokencomboboxes

@wrinch
Copy link
Author

wrinch commented Jun 6, 2018

Gah, OK, I fail,

I didn't realize that I shouldn't call the OpenPopup all the time. This code works just fine:

static bool opened = false;
if (!opened) {
	opened = true;
	ImGui::OpenPopup("BrokenComboBoxes");
}	
if (ImGui::BeginPopupModal("BrokenComboBoxes", nullptr, 0)) {
	static int loggingLevel = 0;
	static const char* logLevels[] = {
		"Trace",
		"Debug",
		"Info",
		"Warn",
		"Error",
		"Critical"
	};
	ImGui::Combo("Logging Level", &loggingLevel, logLevels, IM_ARRAYSIZE(logLevels));
	ImGui::EndPopup();
}

@wrinch wrinch closed this as completed Jun 6, 2018
@ocornut ocornut added the popups label Jun 6, 2018
ocornut added a commit that referenced this issue Jun 6, 2018
…p() to not fully close/re-open the popup so its child popups won't get closed. (#1497, #1533, #1865).

Followup/fix the change made in deab2ab
@ocornut
Copy link
Owner

ocornut commented Jun 6, 2018

This is a common mistake unfortunately.

As part of #1497 I actually had introduced a measure to alleviate the issues caused by this, and it was incomplete. I have now pushed a fix that will also prevent the child popups from being closed. (See commit above to understand). So you actually reported a bug :) Thanks!

The thing is, it is useful to call OpenPopup() again (the most common use case being that right-click context menus are typically reopened when you right-click again) and that means closing the child popups. So we have a special case were we catch when the user calls it every frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants