mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse click. Note that they don't use the full ButtonBehavior() or tracking aabb on both click and release. Applications I've tried seems to behave inconsistently there but on-release-without-tracking is both fairly common and doesn't require extra code for the id tracking. (~#439)
This commit is contained in:
parent
c337cdcfd3
commit
63e4677b81
10
imgui.cpp
10
imgui.cpp
@ -3904,7 +3904,7 @@ void ImGui::EndPopup()
|
|||||||
bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
|
bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
if (IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
{
|
{
|
||||||
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
||||||
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
||||||
@ -3922,8 +3922,7 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
|||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
||||||
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
||||||
if (IsMouseClicked(mouse_button))
|
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
||||||
OpenPopupEx(id, true);
|
OpenPopupEx(id, true);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
}
|
}
|
||||||
@ -3933,8 +3932,7 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool a
|
|||||||
if (!str_id)
|
if (!str_id)
|
||||||
str_id = "window_context";
|
str_id = "window_context";
|
||||||
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
|
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
|
||||||
if (IsMouseClicked(mouse_button))
|
if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||||
if (IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
||||||
if (also_over_items || !IsAnyItemHovered())
|
if (also_over_items || !IsAnyItemHovered())
|
||||||
OpenPopupEx(id, true);
|
OpenPopupEx(id, true);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
@ -3945,7 +3943,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
|
|||||||
if (!str_id)
|
if (!str_id)
|
||||||
str_id = "void_context";
|
str_id = "void_context";
|
||||||
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
|
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
|
||||||
if (!IsAnyWindowHovered() && IsMouseClicked(mouse_button))
|
if (IsMouseReleased(mouse_button) && !IsAnyWindowHovered())
|
||||||
OpenPopupEx(id, true);
|
OpenPopupEx(id, true);
|
||||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user