-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue programmatically setting Scrolling with SetScrollHereY() in window with clipped contents #8212
Comments
@ocornut It seems that setting y is invalid when the column is not displayed |
I can solve some problems in this way, But I don't think that's a good idea if (ImGui::IsRectVisible(ImGui::GetContentRegionAvail())){
drawCol();
} |
The problem you have is that Possible solutions: if (ImGui::BeginChild("chatBeginChild_2", ImVec2(300, 300), ImGuiChildFlags_Borders))
{
int scroll_index2 = 49;
for (size_t j = 0; j < 50; j++)
{
ImGui::TextColored(ImVec4(1, 1, 1, 1), "%d %d", j, scroll_index2);
if (need_to_set_scroll2 && scroll_index2 == j)
{
need_to_set_scroll2 = false;
IMGUI_DEBUG_LOG("SetScrollHereY2 called\n");
ImGui::SetScrollHereY(0.5f);
}
}
}
ImGui::EndChild(); And (B) Either you compute the scroll target rather than rely on current layout: ImGui::BeginChild("chatBeginChild_2", ImVec2(300, 300), ImGuiChildFlags_Borders);
int scroll_index2 = 49;
if (need_to_set_scroll2)
{
ImGui::SetScrollY(ImGui::GetTextLineHeightWithSpacing() * scroll_index2);
need_to_set_scroll2 = false;
}
for (size_t j = 0; j < 50; j++)
ImGui::TextColored(ImVec4(1, 1, 1, 1), "%d %d", j, scroll_index2);
ImGui::EndChild(); |
Version/Branch of Dear ImGui:
Version 1.XX, Branch: XXX (master/docking/etc.)
Back-ends:
imgui_impl_XXX.cpp + imgui_impl_XXX.cpp
Compiler, OS:
win10
Full config/build information:
No response
Details:
why I need to click twice to get the scroll bar at right pos
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: