Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502)

This commit is contained in:
omar
2017-12-14 18:42:41 +01:00
parent ac8e708c3e
commit eefea0588a
3 changed files with 20 additions and 7 deletions

View File

@ -997,6 +997,9 @@ void ImGui::ShowTestWindow(bool* p_open)
{
if (ImGui::TreeNode("Child regions"))
{
static bool disable_mouse_wheel = false;
ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel);
ImGui::Text("Without border");
static int line = 50;
bool goto_line = ImGui::Button("Goto");
@ -1004,7 +1007,8 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::PushItemWidth(100);
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopItemWidth();
ImGui::BeginChild("Sub1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f,300), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::BeginChild("Sub1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f,300), false, ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0));
for (int i = 0; i < 100; i++)
{
ImGui::Text("%04d: scrollable region", i);
@ -1018,7 +1022,7 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::SameLine();
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
ImGui::BeginChild("Sub2", ImVec2(0,300), true);
ImGui::BeginChild("Sub2", ImVec2(0,300), true, (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0));
ImGui::Text("With border");
ImGui::Columns(2);
for (int i = 0; i < 100; i++)