zoukankan      html  css  js  c++  java
  • 修复 XE7 , XE8 Frame 内 PopupMenu 快捷键失效问题

    问题:将 Frame 含 PopupMenu 放置 Form 后,在 Frame 里的 PopupMenu 失效,无法按快捷键。

    适用:(XE7 update 1 / XE8) 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;
  • 相关阅读:
    JSOIWC2019游记
    基础网络流题单
    【题解】Luogu P2472 [SCOI2007]蜥蜴
    【题解】Luogu P2057 [SHOI2007]善意的投票
    凸包略解
    【题解】Luogu P4324 [JSOI2016]扭动的回文串
    【题解】Luogu P4054 [JSOI2009]计数问题
    kruscal重构树略解
    【题解】bzoj 4478 [Jsoi2013]侦探jyy
    【题解】4465 [Jsoi2013]游戏中的学问
  • 原文地址:https://www.cnblogs.com/onechen/p/4355349.html
Copyright © 2011-2022 走看看