[Demo] Selectable covering Button on the same line, is this by design? #6574

Closed
opened 2023-07-05 02:04:37 +00:00 by Demonese · 5 comments
Demonese commented 2023-07-05 02:04:37 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version: 1.89.7
Branch: features/range_select

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler: MSVC 19.36.32535
Operating System: Windows 11 22H2

My Issue/Question:

Is this by design?

EX: I didn't find any API that can change the z-order of widgets, maybe some related APIs should be added

Screenshots/Video

D9F336B8960E14478878702A81492E2F

Standalone, minimal, complete and verifiable example:

**Version/Branch of Dear ImGui:** Version: 1.89.7 Branch: features/range_select **Back-end/Renderer/Compiler/OS** Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp Compiler: MSVC 19.36.32535 Operating System: Windows 11 22H2 **My Issue/Question:** Is this by design? _EX: I didn't find any API that can change the z-order of widgets, maybe some related APIs should be added_ **Screenshots/Video** ![D9F336B8960E14478878702A81492E2F](https://github.com/ocornut/imgui/assets/57629614/6fda840d-e371-40fa-8089-576ee7caf60b) **Standalone, minimal, complete and verifiable example:**
GamingMinds-DanielC commented 2023-07-05 09:01:46 +00:00 (Migrated from github.com)

Hard to say without any code, but it seems you have ImGuiTreeNodeFlags_SpanAvailWidth active. Using the available with is the purpose of that flag.

Edit: ah, those leaves are selectables in the demo code. But in the demo code they just have text after them, in that case an expanded selectable would be desired. The buttons are your addition, you would have to adjust the selectables accordingly.

Hard to say without any code, but it seems you have `ImGuiTreeNodeFlags_SpanAvailWidth` active. Using the available with is the purpose of that flag. Edit: ah, those leaves are selectables in the demo code. But in the demo code they just have text after them, in that case an expanded selectable would be desired. The buttons are your addition, you would have to adjust the selectables accordingly.
PathogenDavid commented 2023-07-05 11:20:16 +00:00 (Migrated from github.com)

You need to call SetNextItemAllowOverlap to explicitly enable support for overlapping widgets.

IE:

static bool selected[3] = { false, false, false };
ImGui::SetNextItemAllowOverlap();
ImGui::Selectable("main.c",    &selected[0]);
ImGui::SameLine();
ImGui::Button("Link 1");

ImGui::SetNextItemAllowOverlap();
ImGui::Selectable("Hello.cpp", &selected[1]);
ImGui::SameLine();
ImGui::Button("Link 2");

ImGui::SetNextItemAllowOverlap();
ImGui::Selectable("Hello.h",   &selected[2]);
ImGui::SameLine();
ImGui::Button("Link 3");
You need to call `SetNextItemAllowOverlap` to explicitly enable support for overlapping widgets. IE: ```cpp static bool selected[3] = { false, false, false }; ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(); ImGui::Button("Link 1"); ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(); ImGui::Button("Link 2"); ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(); ImGui::Button("Link 3"); ```
Demonese commented 2023-07-05 11:32:16 +00:00 (Migrated from github.com)

You need to call SetNextItemAllowOverlap to explicitly enable support for overlapping widgets.

This is a new API, I didn't understand what it did at first, thanks for the answer!

D1CDC273E7AF9E4FBDD98754BF1F09CD

> You need to call `SetNextItemAllowOverlap` to explicitly enable support for overlapping widgets. This is a new API, I didn't understand what it did at first, thanks for the answer! ![D1CDC273E7AF9E4FBDD98754BF1F09CD](https://github.com/ocornut/imgui/assets/57629614/479f1c31-7d5e-442b-ae34-f90a291cdf12)
ocornut commented 2023-07-05 11:56:33 +00:00 (Migrated from github.com)

Thank you for pointing this out.
Actually I think it was a mistake that I committed it in range_select branch, I recall it was a test and I didn't finish the thing.
I will rework this section so the button look the right size + use SetNextItemAllowOverlap() here and there.

Thank you for pointing this out. Actually I think it was a mistake that I committed it in range_select branch, I recall it was a test and I didn't finish the thing. I will rework this section so the button look the right size + use `SetNextItemAllowOverlap()` here and there.
ocornut commented 2023-07-05 12:20:40 +00:00 (Migrated from github.com)

I have pushed 9a15730 with some use of SetNextItemAllowOverlap() in the demo.

I have pushed 9a15730 with some use of SetNextItemAllowOverlap() in the demo.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#6574
No description provided.