Skip to content

Commit 3d25834

Browse files
committed
Fix hotkey config clobbering all hotkeys
We need to take copies of the name and gesture before unregistering and re-registering.
1 parent c769ee5 commit 3d25834

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

SpeechResponder/ConfigurationWindow.xaml.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Windows;
1515
using System.Windows.Controls;
1616
using System.Windows.Data;
17+
using System.Windows.Input;
1718
using System.Windows.Threading;
1819
using Utilities;
1920

@@ -453,13 +454,16 @@ private void configureHotkeysButtonClicked ( object sender, RoutedEventArgs e )
453454
// Register the new hotkey configuration
454455
foreach ( var actionKeyGesture in window.HotkeyActionCollection.HotkeyActions )
455456
{
457+
string name = actionKeyGesture.Name;
458+
KeyGesture gesture = actionKeyGesture.KeyGesture;
459+
456460
// Unregister the old hotkey if it exists
457-
hkm.UnregisterHotkey( actionKeyGesture.Name );
461+
hkm.UnregisterHotkey( name );
458462

459463
// Assign a new hotkey if a gesture is set
460-
if ( actionKeyGesture.KeyGesture != null )
464+
if ( gesture != null )
461465
{
462-
hkm.RegisterHotkey( actionKeyGesture.Name, actionKeyGesture.KeyGesture );
466+
hkm.RegisterHotkey( name, gesture );
463467
}
464468
}
465469
}

0 commit comments

Comments
 (0)