1
0
Эх сурвалжийг харах

Bug fix: Some control labels were showing keyboard accelerators without keyboard intervention (see also 4031057b) + Bug fix: Pressing Alt with some combo boxes focused did not show keyboard accelerators (see also 822683ed)

Source commit: 754677b7d1a02e8e29dfe54c4bdcd08b783078b0
Martin Prikryl 2 жил өмнө
parent
commit
f4aae36d36

+ 1 - 1
source/forms/Authenticate.cpp

@@ -209,7 +209,7 @@ void __fastcall TAuthenticateForm::AdjustControls()
 //---------------------------------------------------------------------------
 TLabel * __fastcall TAuthenticateForm::GenerateLabel(int Current, UnicodeString Caption)
 {
-  TLabel * Result = new TLabel(this);
+  TLabel * Result = new TUIStateAwareLabel(this);
   Result->Parent = FPromptParent;
 
   Result->Anchors = TAnchors() << akLeft << akTop << akRight;

+ 10 - 14
source/forms/Custom.cpp

@@ -175,7 +175,7 @@ TCheckBox * __fastcall TCustomDialog::CreateAndAddCheckBox(const UnicodeString &
 //---------------------------------------------------------------------------
 TLabel * __fastcall TCustomDialog::CreateLabel(UnicodeString Label)
 {
-  TLabel * Result = new TLabel(this);
+  TLabel * Result = new TUIStateAwareLabel(this);
   Result->Caption = Label;
   return Result;
 }
@@ -462,7 +462,7 @@ void __fastcall TSaveSessionDialog::Init(bool CanSavePassword,
   DebugAssert(!Folders->CaseSensitive);
   Folders->Sort();
 
-  FolderCombo = new TComboBox(this);
+  FolderCombo = new TUIStateAwareComboBox(this);
   AddComboBox(FolderCombo, CreateLabel(LoadStr(SAVE_SESSION_FOLDER)));
   FolderCombo->DropDownCount = Max(FolderCombo->DropDownCount, 16);
   FolderCombo->Items->Add(FRootFolder);
@@ -669,7 +669,7 @@ __fastcall TSaveWorkspaceDialog::TSaveWorkspaceDialog(
 {
   Caption = LoadStr(SAVE_WORKSPACE_CAPTION);
 
-  WorkspaceNameCombo = new TComboBox(this);
+  WorkspaceNameCombo = new TUIStateAwareComboBox(this);
   WorkspaceNameCombo->AutoComplete = false;
   AddComboBox(WorkspaceNameCombo, CreateLabel(LoadStr(SAVE_WORKSPACE_PROMPT)));
   WorkspaceNameCombo->DropDownCount = Max(WorkspaceNameCombo->DropDownCount, 16);
@@ -767,7 +767,7 @@ __fastcall TShortCutDialog::TShortCutDialog(const TShortCuts & ShortCuts, Unicod
 {
   Caption = LoadStr(SHORTCUT_CAPTION);
 
-  ShortCutCombo = new TComboBox(this);
+  ShortCutCombo = new TUIStateAwareComboBox(this);
   AddShortCutComboBox(ShortCutCombo, CreateLabel(LoadStr(SHORTCUT_LABEL)), ShortCuts);
 }
 //---------------------------------------------------------------------------
@@ -1022,7 +1022,7 @@ __fastcall TCustomCommandOptionsDialog::TCustomCommandOptionsDialog(
       }
       else if (Option.Kind == TCustomCommandType::okDropDownList)
       {
-        TComboBox * ComboBox = new TComboBox(this);
+        TComboBox * ComboBox = new TUIStateAwareComboBox(this);
         ComboBox->Style = csDropDownList;
 
         AddOptionComboBox(ComboBox, Value, Option, Values);
@@ -1031,7 +1031,7 @@ __fastcall TCustomCommandOptionsDialog::TCustomCommandOptionsDialog(
       }
       else if (Option.Kind == TCustomCommandType::okComboBox)
       {
-        TComboBox * ComboBox = new TComboBox(this);
+        TComboBox * ComboBox = new TUIStateAwareComboBox(this);
         ComboBox->Style = csDropDown;
 
         AddOptionComboBox(ComboBox, Value, Option, Values);
@@ -1078,7 +1078,7 @@ __fastcall TCustomCommandOptionsDialog::TCustomCommandOptionsDialog(
     {
       AddSeparator();
     }
-    FShortCutCombo = new TComboBox(this);
+    FShortCutCombo = new TUIStateAwareComboBox(this);
     AddShortCutComboBox(FShortCutCombo, CreateLabel(LoadStr(EXTENSION_SHORTCUT)), *ShortCuts);
   }
 }
@@ -1387,16 +1387,12 @@ __fastcall TUsageStatisticsDialog::TUsageStatisticsDialog() :
   Caption = LoadStr(USAGE_CAPTION);
   Width = ScaleByTextHeight(this, 400);
 
-  TLabel * Label = new TLabel(this);
   // UnformatMessage is called, because previously, ** markup was used and translations may still contain that
-  Label->Caption = UnformatMessage(LoadStr(USAGE_DATA2));
-  AddText(Label);
+  AddText(CreateLabel(UnformatMessage(LoadStr(USAGE_DATA2))));
 
   FilterEdit = new TEdit(this);
   FilterEdit->Width = ScaleByTextHeight(this, 250);
-  TLabel * FilterLabel = new TLabel(this);
-  FilterLabel->Caption = LoadStr(USAGE_FILTER);
-  AddEdit(FilterEdit, FilterLabel, true);
+  AddEdit(FilterEdit, CreateLabel(LoadStr(USAGE_FILTER)), true);
 
   UsageMemo = new TMemo(this);
   UsageMemo->Height = ScaleByTextHeight(this, 300);
@@ -1552,7 +1548,7 @@ void __fastcall TSiteRawDialog::AddButtonClick(TObject *)
 
   std::unique_ptr<TCustomDialog> AddDialog(new TCustomDialog(HelpKeyword));
   AddDialog->Caption = LoadStr(SITE_RAW_ADD_CAPTION);
-  TComboBox * AddComboBox = new TComboBox(AddDialog.get());
+  TComboBox * AddComboBox = new TUIStateAwareComboBox(AddDialog.get());
   AddComboBox->Style = csDropDownList;
   AddComboBox->DropDownCount = Max(AddComboBox->DropDownCount, 16);
   AddDialog->AddComboBox(AddComboBox, CreateLabel(LoadStr(SITE_RAW_ADD_LABEL)), Names.get(), true);

+ 1 - 1
source/forms/EditorPreferences.cpp

@@ -79,7 +79,7 @@ void __fastcall TEditorPreferencesDialog::Init(TEditorPreferencesMode Mode, bool
     ExternalEditorBrowseButton->Top = ExternalEditorBrowseButton->Top - Shift;
     Shift += (EditorExternalButton->Top - EditorInternalButton->Top);
     EditorGroup2->Height = EditorGroup2->Height - Shift;
-    TLabel * ExternalEditorLabel = new TLabel(this);
+    TLabel * ExternalEditorLabel = new TUIStateAwareLabel(this);
     ExternalEditorLabel->Caption = EditorExternalButton->Caption;
     ExternalEditorLabel->Parent = EditorGroup2;
     ExternalEditorLabel->Top = MaskLabel->Top;

+ 2 - 2
source/forms/LocationProfiles.cpp

@@ -90,7 +90,7 @@ __fastcall TBookmarkNameDialog::TBookmarkNameDialog(TStrings * PeerBookmarks,
 {
   Caption = LoadStr(ADD_BOOKMARK_CAPTION);
 
-  NameCombo = new TComboBox(this);
+  NameCombo = new TUIStateAwareComboBox(this);
   NameCombo->AutoComplete = false;
   NameCombo->DropDownCount = Max(NameCombo->DropDownCount, 16);
   AddComboBox(NameCombo, CreateLabel(LoadStr(ADD_BOOKMARK_PROMPT)));
@@ -156,7 +156,7 @@ __fastcall TBookmarkFolderDialog::TBookmarkFolderDialog(TStrings * Folders) :
 {
   Caption = LoadStr(MOVE_BOOKMARK_CAPTION);
 
-  NameCombo = new TComboBox(this);
+  NameCombo = new TUIStateAwareComboBox(this);
   NameCombo->AutoComplete = false;
   AddComboBox(NameCombo, CreateLabel(LoadStr(MOVE_BOOKMARK_PROMPT)));
   NameCombo->Items = Folders;

+ 5 - 0
source/windows/GUITools.cpp

@@ -2305,6 +2305,11 @@ static int HideAccelFlag(TControl * Control)
   return Result;
 }
 //---------------------------------------------------------------------------
+__fastcall TUIStateAwareLabel::TUIStateAwareLabel(TComponent * AOwner) :
+  TLabel(AOwner)
+{
+}
+//---------------------------------------------------------------------------
 void __fastcall TUIStateAwareLabel::DoDrawText(TRect & Rect, int Flags)
 {
   if (ShowAccelChar)

+ 3 - 0
source/windows/GUITools.h

@@ -188,6 +188,9 @@ private:
 // https://stackoverflow.com/q/4685863/850848
 class TUIStateAwareLabel : public TLabel
 {
+public:
+  __fastcall virtual TUIStateAwareLabel(TComponent * AOwner);
+
 protected:
   DYNAMIC void __fastcall DoDrawText(TRect & Rect, int Flags);
 };