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

How can I click a button in a table column easily #53

Open
mgerhardy opened this issue Jun 17, 2024 · 1 comment
Open

How can I click a button in a table column easily #53

mgerhardy opened this issue Jun 17, 2024 · 1 comment

Comments

@mgerhardy
Copy link

I can see that I have to access a child if the table has a scrollbar, and no child if there is no scrollbar. Is there maybe a helper to hide this fact that I've just not yet seen?

if (ImGui::BeginTable("##someid", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
 ImGui::TableSetupColumn("Col1");
 ImGui::TableSetupColumn("Col2");
 ImGui::TableHeadersRow();
 { // here the for loop
  ImGui::TableNextRow();
  ImGui::TableNextColumn();
  ImGuiTreeNodeFlags treeFlags = ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_SpanAvailWidth;
  if (ImGui::TreeNodeEx("treenode", treeFlags)) {
   if (ImGui::Button("Button1")) {
    // do something
   }
   ImGui::TreePop();
  }
 }
 ImGui::EndTable();
}

I could use ctx->WindowInfo() - but as far as I can see this would only work if the table has the scrolling activated.

@ocornut
Copy link
Owner

ocornut commented Jun 27, 2024

I can see that I have to access a child if the table has a scrollbar, and no child if there is no scrollbar. Is there maybe a helper to hide this fact that I've just not yet seen?
I'll try work on something.

I don't have a great solution to I would like to improve child name/id logic to facilitate this, toward a way where "parent/table" could be the same ID regardless of whether the table has a child window or not.
That, or TestEngine would do iterative lookups on each item of a path.

Note that you can use the "**/Button1" syntax to find an item in child windows, which can be used as a workaround to infer the parent window.

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

2 participants