Objo.
Feedback Forum Docs Objo Studio
Feedback

Feature #1312

Identify the ListBox row at a point

Status
Fixed
Fixed in
v26.8.6
Source discussion
https://forum.objo.dev/d/941-listbox-header-height
Last updated
2026-08-29

Upvotes

0 upvotes

Uses your Objo forum account.

Public summary

Add a public ListBox.RowAtPoint(x, y) method that returns the zero-based index of the visible row currently displayed under the given ListBox-relative logical coordinates, or -1 when the point is not over a row. It is intended for use in ListBox mouse handlers, where it lets a MouseDown handler identify the row that was pressed so the value can be stored for later use by SelectionChanged.

Today a developer who needs to know which row the pointer is over during MouseDown is forced to reconstruct the row from the pointer position, and the natural workaround is to subtract a hard-coded header height (for example 32 points) plus row heights. That is fragile because the header height is theme-dependent. A native hit-testing API solves this correctly: the points received by the inherited MouseDown, MouseUp, MouseMove and MouseDrag events are already ListBox-relative regardless of window, container or scroll position, so RowAtPoint can be fed those coordinates directly and account for headers, scrolling, borders and nesting itself.

For pointer-driven ListBox selection, the Objo MouseDown handler is delivered before SelectionChanged, so the pattern of storing pressedRow = Me.RowAtPoint(x, y) in MouseDown and reading it in SelectionChanged works. This ordering guarantee applies to Objo callbacks; it does not necessarily mean SelectedRowIndex still contains the old selection during MouseDown, because the native control may already have updated its selection internally.

Objo.

Build apps visually, deploy anywhere.

Feedback is a public read-only status mirror for Objo Studio.