I have always written MainMenu in code, using a conditional define "ssCmd" for ssMeta on Macintosh, and ssCtrl on Windows and Linux. For a new project, however, I decided to try the TMainMenu editor in the Form Designer.
It works very nicely, but with an apparent catch for Mac. I initially wrote the menu using ssMeta, but discovered that does not work on Windows or Linux. So, I rewrote the menu using ssCtrl, and added the following code to the Form.OnShow event:
{$IFDEF DARWIN}
for mnu0 in mnuMain.Items do begin
for j := 0 to mnu0.Count-1 do begin
mnu1 := mnu0.Items[j];
w := mnu1.ShortCut;
if w.TestBit(14) then begin // 14 ($4000) = ctrl, 12 ($1000) = meta
w := w.ClearBit(14);
w := w.SetBit(12);
mnu1.ShortCut := w;
end;
end;
end;
{$ENDIF}
It works fine, but I wonder if I am doing it the hard way. By the way, it does not seem possible in Windows to choose or delete ssMeta in the TMainMenu editor.
Am I missing something easier? If not, maybe someone will find this code useful. Note that it is written for a simple menu. It would need another loop, or recursion, to account for submenus.
EDIT: I left out the types, w is a word.