Designer: Name Menu separators as "SeparatorX" to make name clashes less likely. Issue #39471.

This commit is contained in:
Juha 2021-11-17 17:24:17 +02:00
parent dda96a3864
commit 641c3a73f0
2 changed files with 11 additions and 6 deletions

View File

@ -5994,7 +5994,7 @@ begin
begin
Designer:=FindRootDesigner(MI);
if Designer<>nil then
MI.Name:=Designer.UniqueName('N');
MI.Name:=Designer.UniqueName('Separator');
end;
end;
SetStrValue(NewValue);

View File

@ -724,7 +724,7 @@ begin
begin
FEditedMenuItem.Caption:=s;
if (s = cLineCaption) and AnsiStartsStr('MenuItem', FEditedMenuItem.Name) then
FEditedMenuItem.Name:=FEditorDesigner.CreateUniqueComponentName('N');
FEditedMenuItem.Name:=FEditorDesigner.CreateUniqueComponentName('Separator');
GlobalDesignHook.RefreshPropertyValues;
GlobalDesignHook.Modified(FEditedMenuItem);
EditedShadow.Invalidate;
@ -1971,17 +1971,22 @@ procedure TShadowBox.AddItemAndShadow(existingSI: TShadowItem;
var
idx: integer;
newMI: TMenuItem;
nm: string;
begin
FShadowMenu.HideFakes;
idx:=existingSI.RealItem.MenuIndex;
if not addBefore then
Inc(idx);
newMI:=TMenuItem.Create(FShadowMenu.LookupRoot);
newMI.Name:=FShadowMenu.FEditorDesigner.CreateUniqueComponentName(newMI.ClassName);
if isSeparator then
newMI.Caption:=cLineCaption
else
if isSeparator then begin
nm:='Separator';
newMI.Caption:=cLineCaption;
end
else begin
nm:=newMI.ClassName;
newMI.Caption:=newMI.Name;
end;
newMI.Name:=FShadowMenu.FEditorDesigner.CreateUniqueComponentName(nm);
existingSI.RealItem.Parent.Insert(idx, newMI);
TShadowItem.CreateWithBoxAndItem(FShadowMenu, existingSI.ParentBox, newMI);
FShadowMenu.UpdateBoxLocationsAndSizes;