Skip to content

Commit 245ea50

Browse files
committed
Allow clicking in the respective other main view to switch focus to it
1 parent 947ffde commit 245ea50

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/gui/controllers/main_view_controller.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts)
6262
{
6363
ViewName: self.context.GetViewName(),
6464
Key: gocui.MouseLeft,
65-
Handler: self.onClick,
65+
Handler: func(opts gocui.ViewMouseBindingOpts) error {
66+
if self.isFocused() {
67+
return self.onClick(opts)
68+
}
69+
70+
self.context.SetParentContext(self.otherContext.GetParentContext())
71+
self.c.Context().Push(self.context, types.OnFocusOpts{
72+
ClickedWindowName: self.context.GetWindowName(),
73+
ClickedViewLineIdx: opts.Y,
74+
})
75+
76+
return nil
77+
},
6678
},
6779
}
6880
}
@@ -104,3 +116,7 @@ func (self *MainViewController) openSearch() error {
104116

105117
return nil
106118
}
119+
120+
func (self *MainViewController) isFocused() bool {
121+
return self.c.Context().Current().GetKey() == self.context.GetKey()
122+
}

0 commit comments

Comments
 (0)