-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
ImGui::Selectable with nested components #2184
Comments
You may call Selectable() first which a non-visible label ( |
Sorry to revive an old post, but I run into the same issue and I more or less managed to make it work so I thought some people might want to know the following. As stated above, using a non-visible label in Selectable, then drawing images/texts work, but the selectable label MUST be unique, otherwise only the first item can be selected. Here is a short example:
This only displays texts (or image/buttons/...) on the same line. To draw on separate lines you indeed need to move the cursor and set the clipping manually. |
You can also use |
Sorry to revive this issue again, but I'm having a problem where if I specify the width of the selectable it stops being drawn above the items that I want, but if I don't specify it overflows into the next item.. Is there a better way to make images selectable? |
Here is an example I got working. Creates a custom Selectable with 2 stacked text fields and a clickable button to the side that opens a modal dialog. ` auto pos = ImGui::GetCursorPos();
` |
I know this is an old one, but the above looks a bit too complicated, here's my solution (I use imgui Java bindings): fun selectableButton(label: String, selected: Boolean, width: Float, height: Float, onSelect: (() -> Unit)? = null, content: (() -> Unit)? = null) {
val cursorPosX = ImGui.getCursorPosX()
if (ImGui.selectable(label, selected, ImGuiSelectableFlags.None, width, height)) {
onSelect?.invoke()
}
ImGui.sameLine()
val afterCursorPosX = ImGui.getCursorPosX()
ImGui.setCursorPosX(cursorPosX)
content?.invoke()
ImGui.sameLine()
ImGui.setCursorPosX(afterCursorPosX)
} |
Is there a way to get
ImGui::Selectable
behavior but have the component be comprised of several other nested components?For example:
Where each
ImGui::Selectable
is contains anImGui::Image
and twoImGui::Text
calls but acts as a single "selectable" item.The text was updated successfully, but these errors were encountered: