feat(tui): click anywhere in row to select monitor or maint item
Use panel zone Pos() to compute clicked row from Y offset instead of per-cell zone matching. Monitors and maint strip both support full-row click selection.
This commit was merged in pull request #167.
This commit is contained in:
+17
-17
@@ -868,9 +868,26 @@ func (m *Model) handleClick(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
if m.bottomPanel == bottomMaint && m.zones.Get("panel-maint").InBounds(msg) {
|
if m.bottomPanel == bottomMaint && m.zones.Get("panel-maint").InBounds(msg) {
|
||||||
m.focusedPanel = panelMaint
|
m.focusedPanel = panelMaint
|
||||||
|
_, relY := m.zones.Get("panel-maint").Pos(msg)
|
||||||
|
row := relY - 2
|
||||||
|
windows := m.activeMaintWindows()
|
||||||
|
if row >= 0 && row < len(windows) {
|
||||||
|
m.maintCursor = row
|
||||||
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
} else if m.zones.Get("panel-monitors").InBounds(msg) {
|
} else if m.zones.Get("panel-monitors").InBounds(msg) {
|
||||||
m.focusedPanel = panelMonitors
|
m.focusedPanel = panelMonitors
|
||||||
|
_, relY := m.zones.Get("panel-monitors").Pos(msg)
|
||||||
|
row := relY - 4 + m.tableOffset
|
||||||
|
if row >= 0 && row < len(m.sites) {
|
||||||
|
m.cursor = row
|
||||||
|
m.syncSelectedID()
|
||||||
|
if m.detailOpen {
|
||||||
|
m.detailScrollOffset = 0
|
||||||
|
return m, m.loadDetailCmd(m.sites[m.cursor].ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
} else if m.zones.Get("panel-logs").InBounds(msg) {
|
} else if m.zones.Get("panel-logs").InBounds(msg) {
|
||||||
m.focusedPanel = panelLogs
|
m.focusedPanel = panelLogs
|
||||||
return m, nil
|
return m, nil
|
||||||
@@ -879,23 +896,6 @@ func (m *Model) handleClick(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
end := m.tableOffset + m.maxTableRows
|
|
||||||
if end > len(m.sites) {
|
|
||||||
end = len(m.sites)
|
|
||||||
}
|
|
||||||
for i := m.tableOffset; i < end; i++ {
|
|
||||||
if m.zones.Get(fmt.Sprintf("site-%d", i)).InBounds(msg) {
|
|
||||||
m.cursor = i
|
|
||||||
m.syncSelectedID()
|
|
||||||
m.focusedPanel = panelMonitors
|
|
||||||
if m.detailOpen {
|
|
||||||
m.detailScrollOffset = 0
|
|
||||||
return m, m.loadDetailCmd(m.sites[m.cursor].ID)
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user