問題:將 Frame 含 PopupMenu 放置 Form 後,在 Frame 裡的 PopupMenu 失效,無法按快捷鍵。
適用:XE7 update 1 for Windows 平台
修正方法:
請將源碼 FMX.Forms.pas 復制到自己的工程目錄裡,再進行修改。
找到 TCommonCustomForm.KeyDown 函數,修改如下:
procedure TCommonCustomForm.KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState); ..... 省略 ...... {+++>} // 遍歷所有的 Menu function FindMenu(c: TFmxObject): TFmxObject; var i: Integer; begin if c is TFmxObject then for i:=0 to TFmxObject(c).ChildrenCount - 1 do begin if TFmxObject(c).Children[i] is TMainMenu then TMainMenu(TFmxObject(c).Children[i]).DialogKey(Key, Shift) else if TFmxObject(c).Children[i] is TPopupMenu then TPopupMenu(TFmxObject(c).Children[i]).DialogKey(Key, Shift); FindMenu(TFmxObject(c).Children[i]); end; end; {<+++} var Control: IControl; begin ..... 省略 ...... // 3. perform key in other Menus for I := ChildrenCount - 1 downto 0 do if Children[i] <> FocusPopup then begin {+++>} FindMenu(Children[I]); // 加入這行:遍歷所有的 Menu if Children[I] is TMainMenu then TMainMenu(Children[I]).DialogKey(Key, Shift) else if Children[I] is TPopupMenu then TPopupMenu(Children[I]).DialogKey(Key, Shift); if Key = 0 then Exit; end; ..... 省略 ...... end;