From c5121702b299ea6f1c3b7021dd71047259aa0be0 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Fri, 30 Apr 2021 22:11:36 +1200 Subject: [PATCH] Fixed the Hotkey selection text Works fine now. No more errant selections. --- DisplayMagician/UIForms/HotkeyForm.Designer.cs | 3 +++ DisplayMagician/UIForms/HotkeyForm.cs | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DisplayMagician/UIForms/HotkeyForm.Designer.cs b/DisplayMagician/UIForms/HotkeyForm.Designer.cs index 0a9e1cf..f5d2c4f 100644 --- a/DisplayMagician/UIForms/HotkeyForm.Designer.cs +++ b/DisplayMagician/UIForms/HotkeyForm.Designer.cs @@ -42,8 +42,10 @@ namespace DisplayMagician.UIForms // txt_hotkey // this.txt_hotkey.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txt_hotkey.HideSelection = false; this.txt_hotkey.Location = new System.Drawing.Point(86, 153); this.txt_hotkey.Name = "txt_hotkey"; + this.txt_hotkey.ReadOnly = true; this.txt_hotkey.Size = new System.Drawing.Size(270, 26); this.txt_hotkey.TabIndex = 1; this.txt_hotkey.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnKeyDown); @@ -153,6 +155,7 @@ namespace DisplayMagician.UIForms this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Choose a Hotkey"; + this.Activated += new System.EventHandler(this.HotkeyForm_Activated); this.ResumeLayout(false); this.PerformLayout(); diff --git a/DisplayMagician/UIForms/HotkeyForm.cs b/DisplayMagician/UIForms/HotkeyForm.cs index 475a144..bd43abf 100644 --- a/DisplayMagician/UIForms/HotkeyForm.cs +++ b/DisplayMagician/UIForms/HotkeyForm.cs @@ -49,7 +49,8 @@ namespace DisplayMagician.UIForms //hks = new HotkeySelector(); //hks.EmptyHotkeyText = ""; //hks.Enable(txt_hotkey); - this.ActiveControl = txt_hotkey; + //this.ActiveControl = txt_hotkey; + //txt_hotkey.DeselectAll(); } #pragma warning disable CS3001 // Argument type is not CLS-compliant @@ -62,9 +63,6 @@ namespace DisplayMagician.UIForms myHotkey = hotkeyToEdit; Refresh(txt_hotkey); - this.ActiveControl = txt_hotkey; - txt_hotkey.DeselectAll(); - if (!String.IsNullOrEmpty(hotkeyHeading)) { if (hotkeyHeading.Length > 60) @@ -91,7 +89,8 @@ namespace DisplayMagician.UIForms this.DialogResult = DialogResult.None; txt_hotkey.Text = ""; myHotkey = Keys.None; - this.ActiveControl = txt_hotkey; + //this.ActiveControl = txt_hotkey; + //txt_hotkey.DeselectAll(); } private void btn_save_Click(object sender, EventArgs e) @@ -282,6 +281,11 @@ namespace DisplayMagician.UIForms _invalidKeyCombination.Add(Keys.Control | Keys.Delete); } - + private void HotkeyForm_Activated(object sender, EventArgs e) + { + //this.ActiveControl = txt_hotkey; + txt_hotkey.Focus(); + txt_hotkey.DeselectAll(); + } } }