浏览代码

Merged from Navigation branch: ImGuiItemFlags_SelectableDontClosePopup flag

omar 8 年之前
父节点
当前提交
926c1cf9a4
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      imgui.cpp
  2. 2 2
      imgui_internal.h

+ 1 - 1
imgui.cpp

@@ -8813,7 +8813,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
     if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
 
     // Automatically close popups
-    if (pressed && !(flags & ImGuiSelectableFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
+    if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup))
         CloseCurrentPopup();
     return pressed;
 }

+ 2 - 2
imgui_internal.h

@@ -580,8 +580,8 @@ enum ImGuiItemFlags_
     ImGuiItemFlags_ButtonRepeat                 = 1 << 1,  // false    // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
     //ImGuiItemFlags_Disabled                   = 1 << 2,  // false    // All widgets appears are disabled
     //ImGuiItemFlags_AllowNavDefaultFocus       = 1 << 3,  // true
-    //ImGuiItemFlags_SelectableDontClosePopup   = 1 << 4,  // false    // MenuItem/Selectable() automatically closes current Popup window
-    ImGuiItemFlags_Default_                 = ImGuiItemFlags_AllowKeyboardFocus
+    ImGuiItemFlags_SelectableDontClosePopup     = 1 << 4,  // false    // MenuItem/Selectable() automatically closes current Popup window
+    ImGuiItemFlags_Default_                     = ImGuiItemFlags_AllowKeyboardFocus
 };
 
 // Transient per-window data, reset at the beginning of the frame