Skip to content

Commit d13d627

Browse files
committed
Allow clicking in the respective other main view to switch focus to it
1 parent 8eb35e2 commit d13d627

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
@@ -58,7 +58,19 @@ func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts)
5858
{
5959
ViewName: self.context.GetViewName(),
6060
Key: gocui.MouseLeft,
61-
Handler: self.onClick,
61+
Handler: func(opts gocui.ViewMouseBindingOpts) error {
62+
if self.isFocused() {
63+
return self.onClick(opts)
64+
}
65+
66+
self.context.SetParentContext(self.otherContext.GetParentContext())
67+
self.c.Context().Push(self.context, types.OnFocusOpts{
68+
ClickedWindowName: self.context.GetWindowName(),
69+
ClickedViewLineIdx: opts.Y,
70+
})
71+
72+
return nil
73+
},
6274
},
6375
}
6476
}
@@ -100,3 +112,7 @@ func (self *MainViewController) openSearch() error {
100112

101113
return nil
102114
}
115+
116+
func (self *MainViewController) isFocused() bool {
117+
return self.c.Context().Current().GetKey() == self.context.GetKey()
118+
}

0 commit comments

Comments
 (0)