diff --git a/headers/private/interface/ColumnListView.h b/headers/private/interface/ColumnListView.h index d2e02f588a..6b9a80054f 100644 --- a/headers/private/interface/ColumnListView.h +++ b/headers/private/interface/ColumnListView.h @@ -297,6 +297,7 @@ public: void RemoveColumn(BColumn* column); int32 CountColumns() const; BColumn* ColumnAt(int32 index) const; + BColumn* ColumnAt(BPoint point) const; void SetColumnVisible(BColumn* column, bool isVisible); void SetColumnVisible(int32, bool); diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index 37ee3eee3d..460aadc005 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -1118,6 +1118,26 @@ BColumnListView::ColumnAt(int32 field) const } +BColumn* +BColumnListView::ColumnAt(BPoint point) const +{ + float left = MAX(kLeftMargin, LatchWidth()); + + for (int i = 0; BColumn* column = (BColumn*)fColumns.ItemAt(i); i++) { + if (!column->IsVisible()) + continue; + + float right = left + column->Width(); + if (point.x >= left && point.x <= right) + return column; + + left = right + 1; + } + + return NULL; +} + + void BColumnListView::SetColumnVisible(BColumn* column, bool visible) {