Skip to content
/ imgui Public
forked from ocornut/imgui

Commit

Permalink
Tabs: avoid queuing a refocus when tab is already focused, which woul…
Browse files Browse the repository at this point in the history
…d have the side-effect of e.g. closing popup on a mouse release. (ocornut#7914)

+ Debug Log: add details about closed popups.
  • Loading branch information
ocornut committed Sep 3, 2024
1 parent 4a06fe5 commit ee9e3a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Other changes:
- Tables: fixes/revert a 1.90 change were outer border would be moved bottom and right
by an extra pixel + rework the change so that contents doesn't overlap the bottom and
right border in a scrolling table. (#6765, #3752, #7428)
- Tabs: avoid queuing a refocus when tab is already focused, which would have the
side-effect of e.g. closing popup on a mouse release. (#7914)
- InputText: allow callback to update buffer while in read-only mode. (imgui_club/#46)
- InputText: fixed an issue programmatically refocusing a multi-line input which was just active. (#4761, #7870)
- TextLink(), TextLinkOpenURL(): change mouse cursor to Hand shape when hovered. (#7885, #7660)
Expand Down
3 changes: 3 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11370,6 +11370,9 @@ void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_
ImGuiContext& g = *GImGui;
IMGUI_DEBUG_LOG_POPUP("[popup] ClosePopupToLevel(%d), restore_under=%d\n", remaining, restore_focus_to_window_under_popup);
IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size);
if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup)
for (int n = remaining; n < g.OpenPopupStack.Size; n++)
IMGUI_DEBUG_LOG_POPUP("[popup] - Closing PopupID 0x%08X Window \"%s\"\n", g.OpenPopupStack[n].PopupId, g.OpenPopupStack[n].Window ? g.OpenPopupStack[n].Window->Name : NULL);

// Trim open popup stack
ImGuiPopupData prev_popup = g.OpenPopupStack[remaining];
Expand Down
2 changes: 1 addition & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9986,7 +9986,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,

// Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget.
const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup);
if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1)) && !is_tab_button)
if (tab_bar->SelectedTabId != tab->ID && hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1)) && !is_tab_button)
TabBarQueueFocus(tab_bar, tab);

if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)
Expand Down

0 comments on commit ee9e3a2

Please sign in to comment.