Skip to content
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

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

Closed
Demonese opened this issue Jul 5, 2023 · 5 comments
Closed

Comments

@Demonese
Copy link
Contributor

Demonese commented Jul 5, 2023

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:

@GamingMinds-DanielC
Copy link
Contributor

GamingMinds-DanielC commented Jul 5, 2023

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
Copy link
Contributor

PathogenDavid commented Jul 5, 2023

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");

@Demonese
Copy link
Contributor Author

Demonese commented Jul 5, 2023

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

@ocornut
Copy link
Owner

ocornut commented Jul 5, 2023

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 added a commit that referenced this issue Jul 5, 2023
…#3909, #517)

+ Merge some shallow changes from range-select branch.
@ocornut
Copy link
Owner

ocornut commented Jul 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants