浏览代码

Bug fix: Using any keyboard shortcut with Alt key shows menu keyboard accelerators permanently

Source commit: ce31117ee0c3be0d3f4c8935c80e3c43545193b6
Martin Prikryl 3 年之前
父节点
当前提交
06db87208c

+ 7 - 0
source/forms/CustomScpExplorer.cpp

@@ -4979,6 +4979,13 @@ void __fastcall TCustomScpExplorerForm::Idle()
         }
       }
     }
+
+    // TB2 shows accels on Alt key down, but hides it only after menu modal loop finishes.
+    // But if Alt is used to switch apps or for keyboard shortcut, the menu modal loop does not happen and accelerators stay displayed.
+    // It's difficult to fix this in TB2, as there's no "up" equivalent to CM_DIALOGKEY, which shows the accels.
+    // And the Alt key can be released even when other window or application is active, so handling the key up in explorer window won't do either.
+    TTBCustomToolbar * MenuToolbar = DebugNotNull(dynamic_cast<TTBCustomToolbar *>(GetComponent(fcMenu)));
+    MenuToolbar->Idle();
   }
 
   if (FShowing || StandaloneOperation)

+ 1 - 0
source/forms/NonVisual.h

@@ -40,6 +40,7 @@
 #define fcLocalPopup       0x26
 #define fcRemotePathComboBox 0x27
 #define fcQueueFileList    0x28
+#define fcMenu             0x29
 
 #define fcExplorerMenuBand        0x31
 #define fcExplorerAddressBand     0x32

+ 1 - 0
source/forms/ScpCommander.cpp

@@ -1194,6 +1194,7 @@ TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
     case fcTransferLabel: return reinterpret_cast<TControl*>(TransferLabel);
     case fcLocalPopup: return reinterpret_cast<TControl *>(NonVisualDataModule->LocalFilePopup);
     case fcRemotePathComboBox: return reinterpret_cast<TControl*>(RemotePathComboBox);
+    case fcMenu: return MenuToolbar;
 
     case fcCommanderMenuBand: return MenuToolbar;
     case fcCommanderSessionBand: return SessionToolbar2;

+ 1 - 0
source/forms/ScpExplorer.cpp

@@ -213,6 +213,7 @@ TControl * __fastcall TScpExplorerForm::GetComponent(Byte Component)
     case fcTransferList: return reinterpret_cast<TControl*>(TransferList);
     case fcTransferLabel: return reinterpret_cast<TControl*>(TransferLabel);
     case fcRemotePathComboBox: return reinterpret_cast<TControl*>(UnixPathComboBox);
+    case fcMenu: return MenuToolbar;
 
     case fcExplorerMenuBand: return MenuToolbar;
     case fcExplorerAddressBand: return AddressToolbar;

+ 11 - 0
source/packages/tb2k/TB2Toolbar.pas

@@ -177,6 +177,7 @@ type
     procedure ReadPositionData(var S: string); override;
     function WritePositionData: string; override;
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
+    procedure Idle;
 
     property ChevronHint: String read GetChevronHint write SetChevronHint stored IsChevronHintStored;
     property ChevronMoveItems: Boolean read FChevronMoveItems write SetChevronMoveItems default True;
@@ -846,6 +847,16 @@ begin
   inherited;
 end;
 
+procedure TTBCustomToolbar.Idle;
+begin
+  if FMenuBar and
+     (not (vsModal in FView.State)) and
+     ((GetAsyncKeyState(VK_MENU) and $8000) = 0) then
+  begin
+    FView.SetAccelsVisibility(False);
+  end;
+end;
+
 procedure TTBCustomToolbar.CMDialogChar(var Message: TCMDialogChar);
 begin
   { On toolbars that aren't menu bars, handle CM_DIALOGCHAR instead of