cocoa: use number of items, of inserting a menu item for the first time

git-svn-id: trunk@62701 -
This commit is contained in:
dmitry 2020-03-07 03:25:08 +00:00
parent d9daa6776b
commit dfd2b9ea65

View File

@ -512,6 +512,7 @@ var
item : NSMenuItem;
MenuObj : NSObject;
Menu : NSMenu;
idx : Integer;
begin
if not Assigned(AMenuItem) or (AMenuItem.Handle=0) or not Assigned(AMenuItem.Parent) or (AMenuItem.Parent.Handle=0) then Exit;
ParObj:=NSObject(AMenuItem.Parent.Handle);
@ -549,7 +550,11 @@ begin
end;
if Assigned(item) then
Parent.insertItem_atIndex(NSMenuItem(item), AMenuItem.MenuVisibleIndex)
begin
idx := AMenuItem.MenuVisibleIndex;
if idx < 0 then idx := Parent.numberOfItems;
Parent.insertItem_atIndex(NSMenuItem(item), idx)
end;
end;
{------------------------------------------------------------------------------