From 800b6f095f95ccfb8a7ba9755292332bf97f97ad Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Tue, 22 Oct 2019 18:24:07 -0800 Subject: [PATCH] tdf#127552 Make toolbox highlighting behave as intended This patch provides intended highlight behavior to my understanding of comments found in the toolbox source code. *only highlight when the focus is not inside a child window of a toolbox eg, in an edit control *do not highlight when focus is in a different toolbox *only clear highlight when focus is not in toolbar Change-Id: Ia18d35c4255ed0940bce5f0c6d9448ed2c85c6fe Reviewed-on: https://gerrit.libreoffice.org/81356 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- vcl/source/window/toolbox.cxx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 7d0f56c9e804..3b0d6b5a5f7e 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -3068,8 +3068,24 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt ) // eg, in an edit control // and do not highlight when focus is in a different toolbox bool bDrawHotSpot = true; - vcl::Window *pWin = Application::GetFocusWindow(); - if( pWin && pWin->ImplGetWindowImpl()->mbToolBox && pWin != this ) + vcl::Window *pFocusWin = Application::GetFocusWindow(); + + bool bFocusWindowIsAToolBoxChild = false; + if (pFocusWin) + { + vcl::Window *pWin = pFocusWin->GetParent(); + while (pWin) + { + if(pWin->ImplGetWindowImpl()->mbToolBox) + { + bFocusWindowIsAToolBoxChild = true; + break; + } + pWin = pWin->GetParent(); + } + } + + if( bFocusWindowIsAToolBoxChild || (pFocusWin && pFocusWin->ImplGetWindowImpl()->mbToolBox && pFocusWin != this) ) bDrawHotSpot = false; if ( mbSelection && bDrawHotSpot ) @@ -3204,7 +3220,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt ) // only clear highlight when focus is not in toolbar bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.IsInside( aMousePos ) && ImplHasClippedItems(); - if ( bClearHigh || bMenuButtonHit ) + if ( !HasFocus() && (bClearHigh || bMenuButtonHit) ) { if ( !bMenuButtonHit && mpData->mbMenubuttonSelected ) { -- 2.11.4.GIT