From dbe82166d02d35e389d88c2829e277b0954a62e3 Mon Sep 17 00:00:00 2001 From: juha Date: Fri, 21 Aug 2020 16:04:36 +0000 Subject: [PATCH] MenuEditor: Update menuitems correctly when adding or removing separators. Patch from BrunoK, issue #37595. git-svn-id: trunk@63803 - --- designer/menueditor.pp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/designer/menueditor.pp b/designer/menueditor.pp index f8ac796651..7455a86df7 100644 --- a/designer/menueditor.pp +++ b/designer/menueditor.pp @@ -2007,9 +2007,14 @@ begin if (sepCount > 0) then begin FShadowMenu.HideFakes; ShowAllUnSelected; - nearestMI:=GetNextNonSepItem(FShadowMenu.SelectedMenuItem); - if (nearestMI = nil) then - nearestMI:=GetPreviousNonSepItem(FShadowMenu.SelectedMenuItem); + nearestMI:=FShadowMenu.SelectedMenuItem; + if assigned(nearestMI) and nearestMI.IsLine then begin + nearestMI:=GetNextNonSepItem(FShadowMenu.SelectedMenuItem); + if (nearestMI = nil) then + nearestMI:=GetPreviousNonSepItem(FShadowMenu.SelectedMenuItem); + end + else + FShadowMenu.SelectedMenuItem := nil; if (nearestMI = nil) then nearestMI:=FParentMenuItem; for i:=ParentMenuItem.Count-1 downto 0 do @@ -2030,6 +2035,7 @@ begin else begin FShadowMenu.UpdateBoxLocationsAndSizes; FShadowMenu.SetSelectedMenuItem(nearestMI, False, True); + LocateShadows; end; end; end; @@ -2042,6 +2048,7 @@ begin if (ShadowList.Count = 0) then Exit; FShadowList.Sort(@SortByItemMenuIndex); + DisableAutoSizing; if IsMenuBar then begin len:=0; for si in FShadowList do begin @@ -2059,6 +2066,7 @@ begin Inc(t, h); end; end; + EnableAutoSizing; end; constructor TShadowBox.CreateWithParentBox(aSMenu: TShadowMenu;