diff --git a/src/Eve-O-Preview/View/Implementation/MainForm.Designer.cs b/src/Eve-O-Preview/View/Implementation/MainForm.Designer.cs index f825221..59fe475 100644 --- a/src/Eve-O-Preview/View/Implementation/MainForm.Designer.cs +++ b/src/Eve-O-Preview/View/Implementation/MainForm.Designer.cs @@ -407,7 +407,7 @@ namespace EveOPreview.View { ToggleTrackingHotkeyTextBox.Name = "ToggleTrackingHotkeyTextBox"; ToggleTrackingHotkeyTextBox.Size = new Size(137, 23); ToggleTrackingHotkeyTextBox.TabIndex = 29; - ToggleTrackingHotkeyTextBox.TextChanged += OptionChanged_Handler; + ToggleTrackingHotkeyTextBox.Leave += HotkeyTextBox_Leave; // // ToggleSingleProcessHotkeyLabel // @@ -426,7 +426,7 @@ namespace EveOPreview.View { ToggleSingleProcessHotkeyTextBox.Name = "ToggleSingleProcessHotkeyTextBox"; ToggleSingleProcessHotkeyTextBox.Size = new Size(137, 23); ToggleSingleProcessHotkeyTextBox.TabIndex = 31; - ToggleSingleProcessHotkeyTextBox.TextChanged += OptionChanged_Handler; + ToggleSingleProcessHotkeyTextBox.Leave += HotkeyTextBox_Leave; // // ToggleAllThumbnailsHotkeyLabel // @@ -445,7 +445,7 @@ namespace EveOPreview.View { ToggleAllThumbnailsHotkeyTextBox.Name = "ToggleAllThumbnailsHotkeyTextBox"; ToggleAllThumbnailsHotkeyTextBox.Size = new Size(137, 23); ToggleAllThumbnailsHotkeyTextBox.TabIndex = 33; - ToggleAllThumbnailsHotkeyTextBox.TextChanged += OptionChanged_Handler; + ToggleAllThumbnailsHotkeyTextBox.Leave += HotkeyTextBox_Leave; // // ThumbnailTabPage // diff --git a/src/Eve-O-Preview/View/Implementation/MainForm.cs b/src/Eve-O-Preview/View/Implementation/MainForm.cs index cdbfd49..8d4885c 100644 --- a/src/Eve-O-Preview/View/Implementation/MainForm.cs +++ b/src/Eve-O-Preview/View/Implementation/MainForm.cs @@ -673,5 +673,36 @@ namespace EveOPreview.View { private void AnimationStyleCombo_SelectedIndexChanged(object sender, EventArgs e) {} private void GeneralSettingsPanel_Paint(object sender, PaintEventArgs e) {} + + private void HotkeyTextBox_Leave(object sender, EventArgs e) { + if (sender is System.Windows.Forms.TextBox textBox) { + string hotkeyText = textBox.Text.Trim(); + + if (!string.IsNullOrEmpty(hotkeyText)) { + try { + // Try to parse the hotkey to validate it + var keysConverter = new KeysConverter(); + var key = keysConverter.ConvertFromInvariantString(hotkeyText); + + if (key == null || (Keys)key == Keys.None) { + MessageBox.Show( + $"Invalid hotkey: {hotkeyText}\n\nPlease enter a valid hotkey combination (e.g., Alt+F1, Ctrl+Shift+A)", + "Invalid Hotkey", MessageBoxButtons.OK, MessageBoxIcon.Warning); + textBox.Focus(); + return; + } + } catch (Exception) { + MessageBox.Show( + $"Invalid hotkey: {hotkeyText}\n\nPlease enter a valid hotkey combination (e.g., Alt+F1, Ctrl+Shift+A)", + "Invalid Hotkey", MessageBoxButtons.OK, MessageBoxIcon.Warning); + textBox.Focus(); + return; + } + } + + // If we get here, the hotkey is valid (or empty), so trigger the option change + this.OptionChanged_Handler(sender, e); + } + } } } \ No newline at end of file