From 98e4cb733fda1c5d38c029af91079630c0c75f0d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 26 Mar 2025 13:43:19 +0100 Subject: [PATCH] Allow clicking in the respective other main view to switch focus to it --- pkg/gui/controllers/main_view_controller.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index b5a6722a5..e6b209286 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -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() +}