You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a table with many columns. In this table the columns will represent values all of the same time, for example all values within one column are integers, or strings, whatever... but all values in each column are the same type. (in this example, all columns are integers)
Now, I want to multi-select cells only within a single column of the table, so I can set all the selected cells to the same value, like this:
This looks like it's working, but I can not 'box select' with mouse around the values I want, I can only use the CTRL + SHIFT and click?
I am not sure why it's not working, because I think it should be.
Screenshots/Video:
In this video, I am using the SHIFT + CTRL keys... Dragging only works at the end outside the table (ScopeWindow flag is used, ScopeRect does not work at all)
ImGuiMultiSelect-2025-01-31_17.07.40.mp4
Minimal, Complete and Verifiable Example code:
// Just call DrawTable() in main loop...staticconstintkNumRows = 10;
staticconstintkNumCols = 4;
staticint g_Data[kNumRows][kNumCols] = {};
voidInitializeTestData()
{
staticbool initialized = false;
if (!initialized)
{
for (int r = 0; r < kNumRows; r++)
for (int c = 0; c < kNumCols; c++)
g_Data[r][c] = (r+1)*100 + c; // arbitrary
initialized = true;
}
}
voidDrawTable(){
InitializeTestData();
static ImGuiSelectionBasicStorage s_Selection;
staticint s_ActiveColumn = -1; // -1 => no column chosen yetImGui::Begin("Table Window");
ImGuiMultiSelectFlags ms_flags =
ImGuiMultiSelectFlags_ClearOnEscape
| ImGuiMultiSelectFlags_ClearOnClickVoid
| ImGuiMultiSelectFlags_BoxSelect2d
| ImGuiMultiSelectFlags_ScopeWindow
| ImGuiMultiSelectFlags_SelectOnClickRelease;
ImGuiTableFlags TABLE_FLAGS = ImGuiTableFlags_Borders | ImGuiTableFlags_ScrollY | ImGuiTableFlags_Resizable;
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(ms_flags, s_Selection.Size, kNumRows);
s_Selection.ApplyRequests(ms_io);
if (ImGui::BeginTable("TestTable", kNumCols, TABLE_FLAGS, ImVec2(0, -24)))
{
ImGui::TableSetupColumn("Col 0");
ImGui::TableSetupColumn("Col 1");
ImGui::TableSetupColumn("Col 2");
ImGui::TableSetupColumn("Col 3");
ImGui::TableHeadersRow();
for (int row = 0; row < kNumRows; row++)
{
ImGui::TableNextRow();
for (int col = 0; col < kNumCols; col++)
{
ImGui::TableSetColumnIndex(col);
int cell_value = g_Data[row][col];
// If no active column chosen yet, any click in this column can activate it// If we already have active column, only that column is selectablebool can_select_this_column = (s_ActiveColumn == -1 || s_ActiveColumn == col);
if (can_select_this_column)
{
// next item -- row indexImGui::SetNextItemSelectionUserData((ImS64)row);
// Is row selected?bool is_selected = s_Selection.Contains((ImGuiID)row);
char label[32];
snprintf(label, sizeof(label), "%d", cell_value);
if (ImGui::Selectable(label, is_selected, ImGuiSelectableFlags_AllowItemOverlap))
{
if (s_Selection.Size == 0)
s_ActiveColumn = col;
}
// If clicked inside this column and it wasn't active before, choose it as active columnif (s_ActiveColumn == -1 && ImGui::IsItemActivated())
{
s_ActiveColumn = col;
}
}
else
{
// Another column is already active, so we are not using a selectable ImGui::Text("%d", cell_value);
}
}
}
ImGui::EndTable();
}
// end multi-select scope
ImGuiMultiSelectIO* ms_io_end = ImGui::EndMultiSelect();
s_Selection.ApplyRequests(ms_io_end);
// clear active column if selection is empty:if (s_Selection.Size == 0)
s_ActiveColumn = -1;
ImGui::Text("Active Column: %d | Selected Rows: %d", s_ActiveColumn, s_Selection.Size);
ImGui::End();
}
The text was updated successfully, but these errors were encountered:
This is driving me insane trying to work out what is happening... :)
I can see the BeginBoxSelect() activate and deactivate, but only if started outside the table, will it actually select anything?
I have tried ImGuiMultiSelectFlags_ScopeRect which shows the BeginBoxSelect() activate and deactivate, but no selection. I have tried ImGuiMultiSelectFlags_BoxSelect1d but it makes no difference.
Version/Branch of Dear ImGui:
1.91.7 docking
Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux, GCC-13
Full config/build information:
Details:
My Issue/Question:
I have a table with many columns. In this table the columns will represent values all of the same time, for example all values within one column are integers, or strings, whatever... but all values in each column are the same type. (in this example, all columns are integers)
Now, I want to multi-select cells only within a single column of the table, so I can set all the selected cells to the same value, like this:
This looks like it's working, but I can not 'box select' with mouse around the values I want, I can only use the CTRL + SHIFT and click?
I am not sure why it's not working, because I think it should be.
Screenshots/Video:
In this video, I am using the SHIFT + CTRL keys... Dragging only works at the end outside the table (ScopeWindow flag is used, ScopeRect does not work at all)
ImGuiMultiSelect-2025-01-31_17.07.40.mp4
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: