MCPcopy Create free account
hub / github.com/docker/docker-agent / handleMouseClick

Method handleMouseClick

cmd/root/agent_picker.go:358–382  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
358func (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

Callers 1

UpdateMethod · 0.95

Calls 4

leanCheckboxAtMethod · 0.95
resetClickTrackingMethod · 0.95
cardAtMethod · 0.95
NowMethod · 0.80

Tested by

no test coverage detected