Add IME state

This commit is contained in:
Vic 2022-12-20 23:13:15 +08:00
parent ce303156fb
commit 9d59933a08
2 changed files with 26 additions and 0 deletions

View file

@ -28,4 +28,28 @@ namespace Flow.Launcher.Converters
throw new NotImplementedException();
}
}
internal class BoolToIMEStateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool v)
{
if (v)
{
return InputMethodState.Off;
}
else
{
return InputMethodState.DoNotCare;
}
}
return InputMethodState.DoNotCare;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View file

@ -39,6 +39,7 @@
<converters:BorderClipConverter x:Key="BorderClipConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter"/>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
@ -207,6 +208,7 @@
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
Visibility="Visible">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />