-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
Description
BeginChildEx cant be found because the child window name contains a '/'. If I change these lines in BegindChildEx:
if (name)
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id);
else
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%/%08X", parent_window->Name, id);
to
if (name)
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s_%s_%08X", parent_window->Name, name, id);
else
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s_%08X", parent_window->Name, id);
i.e replace the slash with an underscore then ImGuiTestContext::ItemInfo can find the child window and doesn't chop off the name_id part.
ImGuiTestItemInfo ImGuiTestContext::ItemInfo(ImGuiTestRef ref, ImGuiTestOpFlags flags)
This is important for scrolling as otherwise items off screen in child windows can't be found as the current work around of serarching via **/name doesn't work.
This has allowed me to do this to scroll the item onto screen in the test framework:
ImGuiWindow* window = ImGui::FindWindowByName(file_dialog);
constexpr const char* child = "##files";
ImGuiID id = window->GetID(child);
std::string child_name = std::format("{}_{}_{:08X}", file_dialog, child, id);
ctx.SetRef(child_name.c_str());
ctx.ScrollToItemY(std::format("##folder_{}", folder).c_str());
There is also a line in
ImGuiTestItemInfo ImGuiTestContext::WindowInfo(ImGuiTestRef ref, ImGuiTestOpFlags flags)
that needs to be changed here:
ImGuiID child_window_id = 0;
ImGuiWindow* child_window = NULL;
{
// Child: Attempt 1: Try to BeginChild(const char*) variant and mimic its logic.
Str128 child_window_full_name;
#if (IMGUI_VERSION_NUM >= 18996) && (IMGUI_VERSION_NUM < 18999)
if (window_idstack_back == window->ID)
{
child_window_full_name.setf("%s/%s", window->Name, part_name.c_str());
}
else
#endif
{
ImGuiID child_item_id = GetID(part_name.c_str(), window_idstack_back);
**** child_window_full_name.setf("%s_%s_%08X", window->Name, part_name.c_str(), child_item_id); ****