diff options
Diffstat (limited to 'go/ui/textBox.go')
| -rw-r--r-- | go/ui/textBox.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/go/ui/textBox.go b/go/ui/textBox.go index 7f1ab98c..2635535c 100644 --- a/go/ui/textBox.go +++ b/go/ui/textBox.go @@ -153,15 +153,26 @@ func (w *PocList) setText() { w.Y = w.bottomY - b.Dy() - w.YMargin } -func (w *PocList) FindObjectAt(x, y int) interface{} { +func (w *PocList) FindObjectAt(_x, _y int) interface{} { + if !w.Contains(_x, _y) { + return nil + } + cards := w.poc.Cards() if len(cards) == 0 { return nil } - // b := text.BoundString(font.Font, w.Text) - // i := b.Dy() / w.poc.Size() - return cards[0] + y := _y - w.Y + + b := text.BoundString(font.Font24, w.text) + i := y / (b.Dy() / w.poc.Size()) + + if i >= len(cards) { + return nil + } + + return cards[i] } type TextInput struct { |
