FMX: TMenuItem shortcuts Ctrl+Alt+O and Ctrl+Alt+A don’t work

  

Setting a TMenuItem Shortcut to Ctrl+Alt+O or Ctrl+Alt+A results in these items not triggering the event when using those shortcuts. However, Ctrl+Alt+B and most others do work. I have not tested all combinations to see which ones work and which ones don’t.
Run the application below and press Ctrl+Alt+A. The Label should show ‘MenuItem2 clicked’, but nothing happens. Press Ctrl+Alt+B and the label shows ‘MenuItem3 clicked’ as expected.
I have already raised the issue here. My question is if anyone knows a workaround? I have tried detecting the keypresses in the form’s OnKeyDown event, but this doesn’t seem to work either. I suspect that this has something to do with typing special characters in Windows. Doing Ctrl+Alt+A in Notepad produces a ‘á’ while Ctrl+Alt+O produces ‘ó’. If I set my Windows language to French then Ctrl+Alt+O now works in the application, but Ctrl+Alt+A still doesn’t.
Note that, VCL applications with menu items with these shortcuts always work fine.
Form:
object Form1: TForm1
Left = 0
Top = 0
Caption = ‘Form1’
ClientHeight = 265
ClientWidth = 355
Position = ScreenCenter
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnKeyDown = FormKeyDown
DesignerMasterStyle = 0
object Label1: TLabel
Position.X = 32.000000000000000000
Position.Y = 96.000000000000000000
Text = ‘Label1’
end
object MainMenu1: TMainMenu
Left = 24
Top = 24
object MenuItem4: TMenuItem
Text = ‘Menu’
object MenuItem1: TMenuItem
Locked = True
ShortCut = 49231
Text = ‘MenuItem1’
OnClick = MenuItem1Click
end
object MenuItem2: TMenuItem
Locked = True
ShortCut = 49217
Text = ‘MenuItem2’
OnClick = MenuItem2Click
end
object MenuItem3: TMenuItem
Locked = True
ShortCut = 49218
Text = ‘MenuItem3’
OnClick = MenuItem3Click
end
end
end
end

Unit:
unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Menus;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
Label1: TLabel;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.MenuItem1Click(Sender: TObject);
begin
Label1.Text := ‘MenuItem1 Clicked’;
end;

procedure TForm1.MenuItem2Click(Sender: TObject);
begin
Label1.Text := ‘MenuItem2 Clicked’;
end;

procedure TForm1.MenuItem3Click(Sender: TObject);
begin
Label1.Text := ‘MenuItem3 Clicked’;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
Caption := KeyChar + ‘ , ‘ + Chr(Key); // Debug
// Below code doesn’t work either
if (ssCtrl in Shift) and (ssAlt in Shift) and (KeyChar = ‘A’) then
MenuItem2Click(Self);
end;

end.

Comments are closed.