Helper to open a popup if mouse button is released over the item - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup()
| 10804 | // Helper to open a popup if mouse button is released over the item |
| 10805 | // - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup() |
| 10806 | void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags) |
| 10807 | { |
| 10808 | ImGuiContext& g = *GImGui; |
| 10809 | ImGuiWindow* window = g.CurrentWindow; |
| 10810 | int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); |
| 10811 | if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) |
| 10812 | { |
| 10813 | ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! |
| 10814 | IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) |
| 10815 | OpenPopupEx(id, popup_flags); |
| 10816 | } |
| 10817 | } |
| 10818 | |
| 10819 | // This is a helper to handle the simplest case of associating one named popup to one given widget. |
| 10820 | // - To create a popup associated to the last item, you generally want to pass a NULL value to str_id. |