handle lostfocus

This commit is contained in:
Hongtao Zhang 2024-04-13 12:53:33 -05:00
parent c9b5159ffd
commit b7ccab67d1
3 changed files with 11 additions and 0 deletions

View file

@ -100,6 +100,7 @@
IsChecked="{Binding Recording}"
KeyboardNavigation.TabNavigation="Continue"
PreviewKeyDown="OnPreviewKeyDown"
LostFocus="HotkeyBtn_OnLostFocus"
Style="{StaticResource {x:Type ToggleButton}}">
<RadioButton.Template>
<ControlTemplate TargetType="RadioButton">

View file

@ -93,5 +93,10 @@ namespace Flow.Launcher
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private void HotkeyBtn_OnLostFocus(object sender, RoutedEventArgs e)
{
_ = ((HotkeyControlViewModel)DataContext).RegisterHotkey();
}
}
}

View file

@ -222,6 +222,11 @@ namespace Flow.Launcher.ViewModel
container.Add(EmptyHotkey);
}
}
public Task RegisterHotkey()
{
return SetHotkeyAsync(Hotkey, true);
}
public Task SetHotkeyAsync(string? keyStr, bool triggerValidate = true)
{