首页 > 其他 > 详细

修复 XE7 Frame 内 PopupMenu 快捷键失效问题

时间:2015-03-21 12:29:45      阅读:376      评论:0      收藏:0      [点我收藏+]

问题:将 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;

 

修复 XE7 Frame 内 PopupMenu 快捷键失效问题

原文:http://www.cnblogs.com/onechen/p/4355349.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!