Skip to content

Commit 9d59933

Browse files
Add IME state
1 parent ce30315 commit 9d59933

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Flow.Launcher/Converters/BoolToIMEConversionModeConverter.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,28 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
2828
throw new NotImplementedException();
2929
}
3030
}
31+
32+
internal class BoolToIMEStateConverter : IValueConverter
33+
{
34+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
35+
{
36+
if (value is bool v)
37+
{
38+
if (v)
39+
{
40+
return InputMethodState.Off;
41+
}
42+
else
43+
{
44+
return InputMethodState.DoNotCare;
45+
}
46+
}
47+
return InputMethodState.DoNotCare;
48+
}
49+
50+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
51+
{
52+
throw new NotImplementedException();
53+
}
54+
}
3155
}

Flow.Launcher/MainWindow.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<converters:BorderClipConverter x:Key="BorderClipConverter" />
4040
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
4141
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
42+
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter"/>
4243
</Window.Resources>
4344
<Window.InputBindings>
4445
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
@@ -207,6 +208,7 @@
207208
Style="{DynamicResource QueryBoxStyle}"
208209
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
209210
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
211+
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
210212
Visibility="Visible">
211213
<TextBox.CommandBindings>
212214
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />

0 commit comments

Comments
 (0)