Strange behaviour with window padding


I’m not sure if it’s an issue actually or I just got something wrong.
I have follwoing code from the examples and modified it to get rid of the main window padding:

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::Begin("Main", nullptr, ImVec2(display_w, display_h), 0.0f, kMainWndFlags);
if (ImGui::BeginMenuBar()) {
	if (ImGui::BeginMenu("File")) {
		if (ImGui::MenuItem("Close", "Ctrl+W")) { = false; }
  ImGui::PopStyleVar(); // padding

If I run this code the main window has no padding as intended but the “file” menu item also has no top padding.
What am I doing wrong here?

See following screenshot:

Thx in advance. Regards.

(That code you posted has unbalanced PopStyleVar() so as-is, this should crash/assert, suggested that you aren’t actually using the code you posted.)

This works well with the current version of imgui:


Your version looks too old you should update.

Hello, thx . Yes indeed :wink:

I got my Version from buckaroo and later discovered there is a newer available.


1 Like