Skip to content

Commit 88b09c5

Browse files
authored
Merge pull request #2664 from onesounds/NVDA20240424
Support Screen Reader
2 parents a288ee4 + 08f7d04 commit 88b09c5

File tree

4 files changed

+56
-28
lines changed

4 files changed

+56
-28
lines changed

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Flow.Launcher.Infrastructure
77
public static class Constant
88
{
99
public const string FlowLauncher = "Flow.Launcher";
10+
public const string FlowLauncherFullName = "Flow Launcher";
1011
public const string Plugins = "Plugins";
1112
public const string PluginMetadataFileName = "plugin.json";
1213

Flow.Launcher/MainWindow.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
Modifiers="Ctrl" />
189189
<KeyBinding
190190
Key="C"
191-
Modifiers="Ctrl+Shift"
192-
Command="{Binding CopyAlternativeCommand}" />
191+
Command="{Binding CopyAlternativeCommand}"
192+
Modifiers="Ctrl+Shift" />
193193
<KeyBinding
194194
Key="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
195195
Command="{Binding TogglePreviewCommand}"
@@ -216,6 +216,7 @@
216216
<TextBox
217217
x:Name="QueryTextBox"
218218
AllowDrop="True"
219+
AutomationProperties.Name="{Binding Results.SelectedItem.Result.Title}"
219220
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
220221
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
221222
PreviewDragOver="OnPreviewDragOver"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,23 @@
2727
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
2828
using DataObject = System.Windows.DataObject;
2929
using System.Windows.Media;
30+
using System.Windows.Interop;
31+
using System.Runtime.InteropServices;
3032

3133
namespace Flow.Launcher
3234
{
3335
public partial class MainWindow
3436
{
3537
#region Private Fields
3638

39+
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
40+
public static extern IntPtr SetForegroundWindow(IntPtr hwnd);
41+
3742
private readonly Storyboard _progressBarStoryboard = new Storyboard();
3843
private bool isProgressBarStoryboardPaused;
3944
private Settings _settings;
4045
private NotifyIcon _notifyIcon;
41-
private ContextMenu contextMenu;
46+
private ContextMenu contextMenu = new ContextMenu();
4247
private MainViewModel _viewModel;
4348
private bool _animating;
4449
MediaPlayer animationSound = new MediaPlayer();
@@ -270,52 +275,56 @@ private void InitializeNotifyIcon()
270275
{
271276
_notifyIcon = new NotifyIcon
272277
{
273-
Text = Infrastructure.Constant.FlowLauncher,
278+
Text = Infrastructure.Constant.FlowLauncherFullName,
274279
Icon = Properties.Resources.app,
275280
Visible = !_settings.HideNotifyIcon
276281
};
277282

278-
contextMenu = new ContextMenu();
279283

280284
var openIcon = new FontIcon
281285
{
282286
Glyph = "\ue71e"
283287
};
284288
var open = new MenuItem
285289
{
286-
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")", Icon = openIcon
290+
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")",
291+
Icon = openIcon
287292
};
288293
var gamemodeIcon = new FontIcon
289294
{
290295
Glyph = "\ue7fc"
291296
};
292297
var gamemode = new MenuItem
293298
{
294-
Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
299+
Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
300+
Icon = gamemodeIcon
295301
};
296302
var positionresetIcon = new FontIcon
297303
{
298304
Glyph = "\ue73f"
299305
};
300306
var positionreset = new MenuItem
301307
{
302-
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon
308+
Header = InternationalizationManager.Instance.GetTranslation("PositionReset"),
309+
Icon = positionresetIcon
303310
};
304311
var settingsIcon = new FontIcon
305312
{
306313
Glyph = "\ue713"
307314
};
308315
var settings = new MenuItem
309316
{
310-
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon
317+
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"),
318+
Icon = settingsIcon
311319
};
312320
var exitIcon = new FontIcon
313321
{
314322
Glyph = "\ue7e8"
315323
};
316324
var exit = new MenuItem
317325
{
318-
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
326+
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
327+
Icon = exitIcon
319328
};
320329

321330
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
@@ -333,17 +342,22 @@ private void InitializeNotifyIcon()
333342
contextMenu.Items.Add(settings);
334343
contextMenu.Items.Add(exit);
335344

336-
_notifyIcon.ContextMenuStrip = new ContextMenuStrip(); // it need for close the context menu. if not, context menu can't close.
337345
_notifyIcon.MouseClick += (o, e) =>
338346
{
339347
switch (e.Button)
340348
{
341349
case MouseButtons.Left:
342350
_viewModel.ToggleFlowLauncher();
343351
break;
344-
345352
case MouseButtons.Right:
353+
346354
contextMenu.IsOpen = true;
355+
// Get context menu handle and bring it to the foreground
356+
if (PresentationSource.FromVisual(contextMenu) is HwndSource hwndSource)
357+
{
358+
_ = SetForegroundWindow(hwndSource.Handle);
359+
}
360+
contextMenu.Focus();
347361
break;
348362
}
349363
};

Flow.Launcher/SettingWindow.xaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@
6767
</Setter.Value>
6868
</Setter>
6969
</Style>
70+
<Style x:Key="SwitchFocusVisualStyleKey">
71+
<Setter Property="Control.Template">
72+
<Setter.Value>
73+
<ControlTemplate>
74+
<Rectangle
75+
Margin="-8,-4,-8,-4"
76+
RadiusX="5"
77+
RadiusY="5"
78+
Stroke="{DynamicResource Color05B}"
79+
StrokeThickness="2" />
80+
</ControlTemplate>
81+
</Setter.Value>
82+
</Setter>
83+
</Style>
7084
<Style x:Key="SettingGrid" TargetType="ItemsControl">
7185
<Setter Property="Focusable" Value="False" />
7286
<Setter Property="Margin" Value="0" />
@@ -137,6 +151,7 @@
137151
<Setter Property="Grid.Column" Value="2" />
138152
<Setter Property="FocusVisualMargin" Value="5" />
139153
<Setter Property="Width" Value="Auto" />
154+
<Setter Property="FocusVisualStyle" Value="{DynamicResource SwitchFocusVisualStyleKey}" />
140155
<Setter Property="HorizontalAlignment" Value="Right" />
141156
<Setter Property="HorizontalContentAlignment" Value="Right" />
142157
<Setter Property="OffContent" Value="{DynamicResource disable}" />
@@ -447,7 +462,10 @@
447462
IsItemsHost="true"
448463
LastChildFill="False" />
449464
<Border Grid.Column="1">
450-
<ContentPresenter Grid.Column="1" ContentSource="SelectedContent" />
465+
<ContentPresenter
466+
x:Name="PART_SelectedContentHost"
467+
Grid.Column="1"
468+
ContentSource="SelectedContent" />
451469
</Border>
452470
</Grid>
453471
</ControlTemplate>
@@ -693,7 +711,7 @@
693711
</ItemsControl>
694712
</Border>
695713

696-
<Border
714+
<Border
697715
Margin="0,30,0,0"
698716
Padding="0"
699717
Style="{DynamicResource SettingGroupBox}">
@@ -720,7 +738,7 @@
720738
<ComboBox
721739
x:Name="SelectScreen"
722740
MinWidth="160"
723-
Margin="0,0,18,0"
741+
Margin="0,0,18,0"
724742
VerticalAlignment="Center"
725743
FontSize="14"
726744
ItemsSource="{Binding ScreenNumbers}"
@@ -738,14 +756,12 @@
738756
</ComboBox>
739757
</StackPanel>
740758
<TextBlock Style="{StaticResource Glyph}">
741-
&#xe7f4;
759+
&#xe7f4;
742760
</TextBlock>
743761
</ItemsControl>
744762
</Border>
745763

746-
<Separator
747-
Width="Auto"
748-
BorderThickness="1">
764+
<Separator Width="Auto" BorderThickness="1">
749765
<Separator.Style>
750766
<Style BasedOn="{StaticResource SettingSeparatorStyle}" TargetType="Separator">
751767
<Setter Property="Visibility" Value="Visible" />
@@ -758,9 +774,7 @@
758774
</Separator.Style>
759775
</Separator>
760776

761-
<Border
762-
Margin="0"
763-
BorderThickness="0">
777+
<Border Margin="0" BorderThickness="0">
764778
<Border.Style>
765779
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
766780
<Setter Property="Visibility" Value="Visible" />
@@ -786,8 +800,7 @@
786800
FontSize="14"
787801
ItemsSource="{Binding SearchWindowAligns}"
788802
SelectedValue="{Binding Settings.SearchWindowAlign}"
789-
SelectedValuePath="Value">
790-
</ComboBox>
803+
SelectedValuePath="Value" />
791804
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
792805
<StackPanel.Style>
793806
<Style TargetType="StackPanel">
@@ -817,7 +830,7 @@
817830
</StackPanel>
818831
</StackPanel>
819832
<TextBlock Style="{StaticResource Glyph}">
820-
&#xe7f4;
833+
&#xe7f4;
821834
</TextBlock>
822835
</ItemsControl>
823836
</Border>
@@ -2446,8 +2459,7 @@
24462459
FontSize="14"
24472460
ItemsSource="{Binding AnimationSpeeds}"
24482461
SelectedValue="{Binding Settings.AnimationSpeed}"
2449-
SelectedValuePath="Value">
2450-
</ComboBox>
2462+
SelectedValuePath="Value" />
24512463
<StackPanel Margin="0,0,18,0" Orientation="Horizontal">
24522464
<StackPanel.Style>
24532465
<Style TargetType="StackPanel">
@@ -2543,7 +2555,7 @@
25432555
TickFrequency="1"
25442556
Value="{Binding SoundEffectVolume, Mode=TwoWay}" />
25452557
</StackPanel>
2546-
<TextBlock Style="{StaticResource Glyph}">
2558+
<TextBlock Style="{StaticResource Glyph}">
25472559
&#xe994;
25482560
</TextBlock>
25492561
</ItemsControl>

0 commit comments

Comments
 (0)