diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0e0c17ec6..9b9a3bb8a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -93,6 +93,7 @@ Other Changes: using the idiom of not applying edits before IsItemDeactivatedAfterEdit(). (#9308, #8915, #8273) - Tables: + - Context menu now presents columns in display order. (#9312) - Fixed and clarified the behavior of using TableSetupScrollFreeze() with columns>1, and where some of the columns within that range were Hidable. - Before: TableSetupScrollFreeze(N, 0) made the first N _visible_ columns diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 348cd2955..bba8fbb87 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -3574,8 +3574,9 @@ void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags want_separator = true; PushItemFlag(ImGuiItemFlags_AutoClosePopups, false); - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) + for (int order_n = 0; order_n < table->ColumnsCount; order_n++) { + const int column_n = table->DisplayOrderToIndex[order_n]; ImGuiTableColumn* column = &table->Columns[column_n]; if (column->Flags & ImGuiTableColumnFlags_Disabled) continue;