MCPcopy Index your code
hub / github.com/docker/docker-agent / handleMouseClick

Method handleMouseClick

pkg/tui/tui.go:2206–2273  ·  view source on GitHub ↗

handleMouseClick routes mouse clicks to the appropriate component based on Y coordinate.

(msg tea.MouseClickMsg)

Source from the content-addressed store, hash-verified

2204
2205// handleMouseClick routes mouse clicks to the appropriate component based on Y coordinate.
2206func (m *appModel) handleMouseClick(msg tea.MouseClickMsg) (tea.Model, tea.Cmd) {
2207 // Check if click hits a notification close button before handling body clicks.
2208 if cmd := m.notification.HandleClick(msg.X, msg.Y); cmd != nil {
2209 return m, cmd
2210 }
2211 if id, text, ok := m.notification.CopyHit(msg.X, msg.Y); ok {
2212 return m, copyNotificationToClipboard(id, text)
2213 }
2214
2215 // Dialogs use full-window coordinates (they're positioned over the entire screen)
2216 if m.dialogMgr.Open() {
2217 // Background dialogs (e.g. pending elicitations) let tab-bar clicks
2218 // pass through so the user can keep navigating between tabs.
2219 if m.dialogMgr.TopIsBackground() && !m.leanMode && m.hitTestRegion(msg.Y) == regionTabBar {
2220 adjustedMsg := msg
2221 adjustedMsg.X = msg.X - styles.AppPadding
2222 adjustedMsg.Y = msg.Y - m.contentHeight - 1
2223 if cmd := m.tabBar.Update(adjustedMsg); cmd != nil {
2224 return m, cmd
2225 }
2226 return m, nil
2227 }
2228 return m.forwardDialog(msg)
2229 }
2230
2231 region := m.hitTestRegion(msg.Y)
2232
2233 switch region {
2234 case regionContent:
2235 return m.forwardChat(msg)
2236
2237 case regionResizeHandle:
2238 if msg.Button == tea.MouseLeft {
2239 m.isDragging = true
2240 }
2241 return m, nil
2242
2243 case regionTabBar:
2244 // Adjust coordinates for tab bar (relative to its start, accounting for padding)
2245 adjustedMsg := msg
2246 adjustedMsg.X = msg.X - styles.AppPadding
2247 adjustedMsg.Y = msg.Y - m.contentHeight - 1
2248 if cmd := m.tabBar.Update(adjustedMsg); cmd != nil {
2249 return m, cmd
2250 }
2251 return m, nil
2252
2253 case regionEditor:
2254 // Focus editor on click
2255 if m.focusedPanel != PanelEditor {
2256 m.focusedPanel = PanelEditor
2257 m.statusBar.InvalidateCache()
2258 m.chatPage.BlurMessages()
2259 }
2260 // Adjust coordinates for editor padding
2261 adjustedMsg := msg
2262 adjustedMsg.X = msg.X - styles.AppPadding
2263 adjustedMsg.Y = msg.Y - m.editorTop()

Callers 1

updateMethod · 0.95

Calls 15

hitTestRegionMethod · 0.95
forwardDialogMethod · 0.95
forwardChatMethod · 0.95
editorTopMethod · 0.95
updateEditorCmdMethod · 0.95
handleSpawnSessionMethod · 0.95
CopyHitMethod · 0.80
BatchMethod · 0.80
ClickedNewTabMethod · 0.80
HandleClickMethod · 0.65
OpenMethod · 0.65

Tested by

no test coverage detected