Skip to content

Commit 862d415

Browse files
committed
Allow clicking in the respective other main view to switch focus to it
1 parent 6d905fb commit 862d415

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/gui/controllers/main_view_controller.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,19 @@ func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts)
5555
{
5656
ViewName: self.context.GetViewName(),
5757
Key: gocui.MouseLeft,
58-
Handler: self.onClick,
58+
Handler: func(opts gocui.ViewMouseBindingOpts) error {
59+
if self.isFocused() {
60+
return self.onClick(opts)
61+
}
62+
63+
self.context.SetParentContext(self.otherContext.GetParentContext())
64+
self.c.Context().Push(self.context, types.OnFocusOpts{
65+
ClickedWindowName: self.context.GetWindowName(),
66+
ClickedViewLineIdx: opts.Y,
67+
})
68+
69+
return nil
70+
},
5971
},
6072
}
6173
}
@@ -105,3 +117,7 @@ func (self *MainViewController) onClick(opts gocui.ViewMouseBindingOpts) error {
105117
}
106118
return nil
107119
}
120+
121+
func (self *MainViewController) isFocused() bool {
122+
return self.c.Context().Current().GetKey() == self.context.GetKey()
123+
}

0 commit comments

Comments
 (0)