ImGuiIDid=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)
OpenPopupEx(id,true);
returntrue;
}
returnfalse;
}
// This is a helper to handle the simplest case of associating one named popup to one given widget.
// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
// this yourself so you can store data relative to the widget that opened the popup instead of choosing different popup identifiers.
// 2. If you want right-clicking on the same item to reopen the popup at new location, use the same code replacing IsItemHovered() with IsItemRectHovered()
// and passing true to the OpenPopupEx().
// This is because hovering an item in a window below the popup won't work. IsItemRectHovered() skips this test.
// The pattern of ignoring the fact that the item can be interacted with (because it is blocked by the active popup) may useful in some situation
// when e.g. large canvas where the content of menu driven by click position.
// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
// You can pass a NULL str_id to use the identifier of the last item.
ImGuiIDid=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)
IMGUI_APIvoidOpenPopup(constchar*str_id);// call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
IMGUI_APIboolOpenPopupOnItemClick(constchar*str_id=NULL,intmouse_button=1);// helper to open popup when clicked on last item. return true when just opened.
IMGUI_APIboolBeginPopup(constchar*str_id);// return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true!
IMGUI_APIboolBeginPopupModal(constchar*name,bool*p_open=NULL,ImGuiWindowFlagsextra_flags=0);// modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside)
IMGUI_APIboolBeginPopupContextItem(constchar*str_id=NULL,intmouse_button=1);// helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
IMGUI_APIboolBeginPopupContextWindow(constchar*str_id=NULL,intmouse_button=1,boolalso_over_items=true);// helper to open and begin popup when clicked on current window.
IMGUI_APIboolBeginPopupContextVoid(constchar*str_id=NULL,intmouse_button=1);// helper to open and begin popup when clicked in void (no window).
IMGUI_APIboolBeginPopupContextVoid(constchar*str_id=NULL,intmouse_button=1);// helper to open and begin popup when clicked in void (where there are no imgui windows).
IMGUI_APIvoidEndPopup();
IMGUI_APIboolIsPopupOpen(constchar*str_id);// return true if the popup is open
IMGUI_APIvoidCloseCurrentPopup();// close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.