Skip to content

Commit c4e5ebb

Browse files
committed
Allow clicking in the respective other main view to switch focus to it
1 parent 3717ca5 commit c4e5ebb

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
@@ -50,7 +50,19 @@ func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts)
5050
{
5151
ViewName: self.context.GetViewName(),
5252
Key: gocui.MouseLeft,
53-
Handler: self.onClick,
53+
Handler: func(opts gocui.ViewMouseBindingOpts) error {
54+
if self.isFocused() {
55+
return self.onClick(opts)
56+
}
57+
58+
self.context.SetParentContext(self.otherContext.GetParentContext())
59+
self.c.Context().Push(self.context, types.OnFocusOpts{
60+
ClickedWindowName: self.context.GetWindowName(),
61+
ClickedViewLineIdx: opts.Y,
62+
})
63+
64+
return nil
65+
},
5466
},
5567
}
5668
}
@@ -80,3 +92,7 @@ func (self *MainViewController) onClick(opts gocui.ViewMouseBindingOpts) error {
8092
}
8193
return nil
8294
}
95+
96+
func (self *MainViewController) isFocused() bool {
97+
return self.c.Context().Current().GetKey() == self.context.GetKey()
98+
}

0 commit comments

Comments
 (0)