LCL: menus: implement StripHotkey (Delphi compatibilty)

git-svn-id: trunk@52307 -
This commit is contained in:
ondrej 2016-05-15 09:26:48 +00:00
parent 2b94ec1a7c
commit 5b3cd06ae3

View File

@ -447,6 +447,7 @@ function NewItem(const ACaption: string; AShortCut: TShortCut;
hCtx: THelpContext; const AName: string): TMenuItem;
function NewLine: TMenuItem;
function StripHotkey(const Text: string): string;
procedure Register;
@ -545,6 +546,34 @@ begin
Result.Caption := cLineCaption;
end;
function StripHotkey(const Text: string): string;
var
I, R: Integer;
begin
SetLength(Result, Length(Text));
I := 1;
R := 1;
while I <= Length(Text) do
begin
if Text[I] = cHotkeyPrefix then
begin
if (I < Length(Text)) and (Text[I+1] = cHotkeyPrefix) then
begin
Result[R] := Text[I];
Inc(R);
Inc(I, 2);
end else
Inc(I);
end else
begin
Result[R] := Text[I];
Inc(R);
Inc(I);
end;
end;
SetLength(Result, R-1);
end;
procedure Register;
begin
RegisterComponents('Standard',[TMainMenu,TPopupMenu]);