LCL: Allow only one "Default" MenuItem per menu or submenu. Issue #41034, patch by Massimo Magnano.

This commit is contained in:
Juha 2024-07-30 09:25:32 +03:00
parent f65e2a2aea
commit d9ef4ae9ab

View File

@ -1203,9 +1203,17 @@ end;
Makes a menuItem the default item (BOLD).
------------------------------------------------------------------------------}
procedure TMenuItem.SetDefault(AValue: Boolean);
var
i: Integer;
begin
if FDefault = AValue then exit;
if AValue and (FParent <> nil) then
// Only one item in a menu or submenu can be default.
for i:=0 to FParent.Count-1 do
if FParent[i].Default then
FParent[i].FDefault := False;
FDefault:= AValue;
//TODO: Add runtime code here
MenuChanged(True);
end;
{------------------------------------------------------------------------------