IDE: Create new MenuItems for bookmarks. A MenuItem cannot be used for many parent menus. Issue #39540.

This commit is contained in:
Juha 2022-01-19 07:57:07 +02:00
parent 4b4b6acc20
commit 4ac1f026c2
3 changed files with 22 additions and 16 deletions

View File

@ -74,6 +74,7 @@ type
function GetImageList: TCustomImageList; virtual;
function HasBitmap: Boolean;
procedure CreateMenuItem; virtual; // only create and set properties, does not add to Section.MenuItem
procedure CreateNewMenuItem;
function GetPath: string;
function GetRoot: TIDEMenuItem;
function VisibleActive: boolean; virtual;
@ -791,6 +792,12 @@ begin
MenuItem:=MenuItemClass.Create(nil);
end;
procedure TIDEMenuItem.CreateNewMenuItem;
begin
FMenuItem.Free;
MenuItem:=MenuItemClass.Create(nil);
end;
function TIDEMenuItem.GetPath: string;
var
Item: TIDEMenuItem;

View File

@ -311,7 +311,6 @@ begin
FPosition := -1;
end;
function TIDEToolButtonsEnumerator.GetCurrent: TIDEToolButton;
begin
Result := FList[FPosition];

View File

@ -1877,16 +1877,16 @@ end;
procedure TToolButton_GotoBookmarks.RefreshMenu;
var
i: TIDEMenuCommand;
cmd: TIDEMenuCommand;
begin
for i in SrcEditMenuGotoBookmark do
if i <> nil then begin
i.CreateMenuItem;
DropdownMenu.Items.Add(i.MenuItem);
for cmd in SrcEditMenuGotoBookmark do
if cmd <> nil then begin
cmd.CreateNewMenuItem;
DropdownMenu.Items.Add(cmd.MenuItem);
end;
DropdownMenu.Items.AddSeparator;
SrcEditMenuPrevBookmark.CreateMenuItem;
SrcEditMenuNextBookmark.CreateMenuItem;
SrcEditMenuPrevBookmark.CreateNewMenuItem;
SrcEditMenuNextBookmark.CreateNewMenuItem;
DropdownMenu.Items.Add([
SrcEditMenuPrevBookmark.MenuItem,
SrcEditMenuNextBookmark.MenuItem]);
@ -1907,19 +1907,19 @@ end;
procedure TToolButton_ToggleBookmarks.RefreshMenu;
var
i: TIDEMenuCommand;
cmd: TIDEMenuCommand;
begin
for i in SrcEditMenuToggleBookmark do
if i <> nil then begin
i.CreateMenuItem;
DropdownMenu.Items.Add(i.MenuItem);
for cmd in SrcEditMenuToggleBookmark do
if cmd <> nil then begin
cmd.CreateNewMenuItem;
DropdownMenu.Items.Add(cmd.MenuItem);
end;
DropdownMenu.Items.AddSeparator;
SrcEditMenuSetFreeBookmark.CreateMenuItem;
SrcEditMenuSetFreeBookmark.CreateNewMenuItem;
DropdownMenu.Items.Add(SrcEditMenuSetFreeBookmark.MenuItem);
DropdownMenu.Items.AddSeparator;
SrcEditMenuClearFileBookmark.CreateMenuItem;
SrcEditMenuClearAllBookmark.CreateMenuItem;
SrcEditMenuClearFileBookmark.CreateNewMenuItem;
SrcEditMenuClearAllBookmark.CreateNewMenuItem;
DropdownMenu.Items.Add([
SrcEditMenuClearFileBookmark.MenuItem,
SrcEditMenuClearAllBookmark.MenuItem]);