Allow clicking in the respective other main view to switch focus to it

This commit is contained in:
Stefan Haller 2025-03-26 13:43:19 +01:00
parent fbb8b2e17e
commit 98e4cb733f

View file

@ -58,7 +58,19 @@ func (self *MainViewController) GetMouseKeybindings(opts types.KeybindingsOpts)
{
ViewName: self.context.GetViewName(),
Key: gocui.MouseLeft,
Handler: self.onClick,
Handler: func(opts gocui.ViewMouseBindingOpts) error {
if self.isFocused() {
return self.onClick(opts)
}
self.context.SetParentContext(self.otherContext.GetParentContext())
self.c.Context().Push(self.context, types.OnFocusOpts{
ClickedWindowName: self.context.GetWindowName(),
ClickedViewLineIdx: opts.Y,
})
return nil
},
},
}
}
@ -100,3 +112,7 @@ func (self *MainViewController) openSearch() error {
return nil
}
func (self *MainViewController) isFocused() bool {
return self.c.Context().Current().GetKey() == self.context.GetKey()
}