handleMouseClick moves the cursor to the clicked card and treats a second left-click on the same card (within the double-click threshold) as a selection. Clicks are ignored while the YAML dialog is open.
(msg tea.MouseClickMsg)
| 356 | // left-click on the same card (within the double-click threshold) as a |
| 357 | // selection. Clicks are ignored while the YAML dialog is open. |
| 358 | func (m *agentPickerModel) handleMouseClick(msg tea.MouseClickMsg) (tea.Model, tea.Cmd) { |
| 359 | if m.showDetails || msg.Button != tea.MouseLeft { |
| 360 | return m, nil |
| 361 | } |
| 362 | if m.leanCheckboxAt(msg.X, msg.Y) { |
| 363 | m.leanMode = !m.leanMode |
| 364 | m.resetClickTracking() |
| 365 | return m, nil |
| 366 | } |
| 367 | i, ok := m.cardAt(msg.X, msg.Y) |
| 368 | if !ok { |
| 369 | m.lastClickIndex = -1 |
| 370 | return m, nil |
| 371 | } |
| 372 | m.cursor = i |
| 373 | |
| 374 | now := time.Now() |
| 375 | if m.lastClickIndex == i && now.Sub(m.lastClickTime) < styles.DoubleClickThreshold { |
| 376 | m.lastClickIndex = -1 |
| 377 | return m, tea.Quit |
| 378 | } |
| 379 | m.lastClickIndex = i |
| 380 | m.lastClickTime = now |
| 381 | return m, nil |
| 382 | } |
| 383 | |
| 384 | // Fixed YAML dialog dimensions. Keeping them constant means the dialog never |
| 385 | // moves or resizes while scrolling. They shrink only when the terminal is too |
no test coverage detected