mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
BeginPopupContextItem() now supports a NULL string identifier and uses the last item ID if available. For interactive items (that have an ID) this works! For non interactive items we assert.
This commit is contained in:
@ -1402,6 +1402,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
|
||||
if (ImGui::TreeNode("Context menus"))
|
||||
{
|
||||
// BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing:
|
||||
// if (IsItemHovered() && IsMouseClicked(0))
|
||||
// OpenPopup(id);
|
||||
// return BeginPopup(id);
|
||||
// For more advanced uses you may want to replicate and cuztomize this code. This the comments inside BeginPopupContextItem() implementation.
|
||||
static float value = 0.5f;
|
||||
ImGui::Text("Value = %.3f (<-- right-click here)", value);
|
||||
if (ImGui::BeginPopupContextItem("item context menu"))
|
||||
@ -1413,9 +1418,9 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
}
|
||||
|
||||
static char name[32] = "Label1";
|
||||
char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceeding label
|
||||
char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label
|
||||
ImGui::Button(buf);
|
||||
if (ImGui::BeginPopupContextItem("rename context menu"))
|
||||
if (ImGui::BeginPopupContextItem()) // When used after an item that has an ID (here the Button), we can skip providing an ID to BeginPopupContextItem().
|
||||
{
|
||||
ImGui::Text("Edit name:");
|
||||
ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
|
||||
|
Reference in New Issue
Block a user