diff --git a/imgui.cpp b/imgui.cpp index 56feaa3a..750b5e50 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2189,9 +2189,9 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar if (g.NavInitDefaultRequest && g.NavLayer == window->DC.NavLayerCurrent) { // Even if 'ImGuiItemFlags_AllowNavDefaultFocus' is off (typically collapse/close button) we record the first ResultId so they can be used as fallback - if (window->DC.ItemFlags & ImGuiItemFlags_AllowNavDefaultFocus) + if (!(window->DC.ItemFlags & ImGuiItemFlags_NoNavDefaultFocus)) g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = false; // Found a match, clear request - if (g.NavInitDefaultResultId == 0 || (window->DC.ItemFlags & ImGuiItemFlags_AllowNavDefaultFocus)) + if (g.NavInitDefaultResultId == 0 || !(window->DC.ItemFlags & ImGuiItemFlags_NoNavDefaultFocus)) { g.NavInitDefaultResultId = *id; g.NavInitDefaultResultRectRel = nav_bb_rel; @@ -5242,7 +5242,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us { // Close & collapse button are on layer 1 (same as menus) and don't default focus const ImGuiItemFlags backup_item_options = window->DC.ItemFlags; - window->DC.ItemFlags &= ~ImGuiItemFlags_AllowNavDefaultFocus; + window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; window->DC.NavLayerCurrent++; // Collapse button diff --git a/imgui_internal.h b/imgui_internal.h index b604262c..2aa49baa 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -167,6 +167,7 @@ inline void operator delete(void*, ImPlacementNewDummy, void*) {} // Types //----------------------------------------------------------------------------- +// NB: Most of those flags are handled by ButtonBehavior(), but some as for the higher level ButtonEx() function only. enum ImGuiButtonFlags_ { ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat @@ -637,9 +638,9 @@ enum ImGuiItemFlags_ ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true 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_NoNavDefaultFocus = 1 << 3, // true ImGuiItemFlags_SelectableDontClosePopup = 1 << 4, // false // MenuItem/Selectable() automatically closes current Popup window - ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus|ImGuiItemFlags_AllowNavDefaultFocus + ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus }; // Transient per-window data, reset at the beginning of the frame