From 93cb759259f444b8fdeaea4743c66acd0e7a4318 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 31 Jul 2022 20:29:27 +0300 Subject: [PATCH] Allow selecting control by clicking edit and hotkey buttons --- .../Controls/HotkeySelectionControl.Designer.cs | 2 +- ShareX/Controls/HotkeySelectionControl.cs | 16 ++++++++++------ ShareX/Controls/HotkeySelectionControl.resx | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ShareX/Controls/HotkeySelectionControl.Designer.cs b/ShareX/Controls/HotkeySelectionControl.Designer.cs index 9061ba32537..64f38758d6b 100644 --- a/ShareX/Controls/HotkeySelectionControl.Designer.cs +++ b/ShareX/Controls/HotkeySelectionControl.Designer.cs @@ -57,7 +57,7 @@ private void InitializeComponent() this.btnTask.Name = "btnTask"; this.btnTask.UseMnemonic = false; this.btnTask.UseVisualStyleBackColor = true; - this.btnTask.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnTask_MouseClick); + this.btnTask.Click += new System.EventHandler(this.btnTask_Click); // // btnHotkey // diff --git a/ShareX/Controls/HotkeySelectionControl.cs b/ShareX/Controls/HotkeySelectionControl.cs index a2cfa837594..d6b0b4c75d7 100644 --- a/ShareX/Controls/HotkeySelectionControl.cs +++ b/ShareX/Controls/HotkeySelectionControl.cs @@ -219,6 +219,12 @@ private void StopEditing() UpdateHotkeyStatus(); } + private void SelectControl() + { + Selected = true; + OnSelectedChanged(); + } + protected void OnHotkeyChanged() { HotkeyChanged?.Invoke(this, EventArgs.Empty); @@ -234,17 +240,14 @@ protected void OnEditRequested() EditRequested?.Invoke(this, EventArgs.Empty); } - private void btnTask_MouseClick(object sender, MouseEventArgs e) + private void btnTask_Click(object sender, EventArgs e) { - if (e.Button == MouseButtons.Left) - { - Selected = true; - OnSelectedChanged(); - } + SelectControl(); } private void btnEdit_Click(object sender, EventArgs e) { + SelectControl(); OnEditRequested(); } @@ -309,6 +312,7 @@ private void btnHotkey_MouseClick(object sender, MouseEventArgs e) } else { + SelectControl(); StartEditing(); } } diff --git a/ShareX/Controls/HotkeySelectionControl.resx b/ShareX/Controls/HotkeySelectionControl.resx index ac5303ed7df..a57cbf664dd 100644 --- a/ShareX/Controls/HotkeySelectionControl.resx +++ b/ShareX/Controls/HotkeySelectionControl.resx @@ -214,7 +214,7 @@ 219, 27 - 3 + 2 Hotkey