Skip to content

Commit c10661d

Browse files
committed
catch NotSupportedException for invalid key combos
1 parent d7dc80f commit c10661d

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

EddiCore/Hotkeys/HotkeysWindow.xaml.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,22 @@ private void HotkeysWindow_KeyDown ( object sender, KeyEventArgs e )
7575
// Validate the key and modifier combination
7676
if ( IsKeyGestureValid( pressedKeys, modifiers ) )
7777
{
78-
// Create a KeyGesture
79-
currentKeyGesture = new KeyGesture( key, modifiers );
80-
81-
// Display the hotkey in the TextBlock
82-
hotkeyTextBlock.Text = currentKeyGesture.GetDisplayStringForCulture( CultureInfo.CurrentCulture ) ??
83-
currentKeyGesture.GetDisplayStringForCulture( CultureInfo.InvariantCulture );
84-
85-
// Prevent the default behavior
86-
e.Handled = true;
78+
try
79+
{
80+
// Create a KeyGesture
81+
currentKeyGesture = new KeyGesture( key, modifiers );
82+
83+
// Display the hotkey in the TextBlock
84+
hotkeyTextBlock.Text = currentKeyGesture.GetDisplayStringForCulture( CultureInfo.CurrentCulture ) ??
85+
currentKeyGesture.GetDisplayStringForCulture( CultureInfo.InvariantCulture );
86+
87+
// Prevent the default behavior
88+
e.Handled = true;
89+
}
90+
catch ( System.NotSupportedException )
91+
{
92+
currentKeyGesture = null;
93+
}
8794
}
8895
else
8996
{

0 commit comments

Comments
 (0)