From 13affe305750be8250f69e4117f0e70cb1ef094f Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:48:00 +0200 Subject: [PATCH] Table.CellAt is now public. Resolves #948 --- table.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/table.go b/table.go index 010b124..66b1bc8 100644 --- a/table.go +++ b/table.go @@ -752,11 +752,14 @@ func (t *Table) GetColumnCount() int { return t.content.GetColumnCount() } -// cellAt returns the row and column located at the given screen coordinates. +// CellAt returns the row and column located at the given screen coordinates. // Each returned value may be negative if there is no row and/or cell. This // function will also process coordinates outside the table's inner rectangle so // callers will need to check for bounds themselves. -func (t *Table) cellAt(x, y int) (row, column int) { +// +// The layout of the table when it was last drawn is used so if anything has +// changed in the meantime, the results may not be reliable. +func (t *Table) CellAt(x, y int) (row, column int) { rectX, rectY, _, _ := t.GetInnerRect() // Determine row as seen on screen. @@ -1648,7 +1651,7 @@ func (t *Table) MouseHandler() func(action MouseAction, event *tcell.EventMouse, consumed = true case MouseLeftClick: selectEvent := true - row, column := t.cellAt(x, y) + row, column := t.CellAt(x, y) cell := t.content.GetCell(row, column) if cell != nil && cell.Clicked != nil { if noSelect := cell.Clicked(); noSelect {