ocornut / ocornut/imgui_test_engine

How can I click a button in a table column easily

Open
#53 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

named references/paths test engine
Dominant language
C++
Stars
629
Forks
83
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown BeginTable/TableNextColumn/Button example with and without ImGuiTableFlags_ScrollY, and inspect how ctx->WindowInfo() is used. Define a helper or API that allows the button to be accessed consistently in both cases, then verify the example works for each table configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.