diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index df5919797d12..df8f9534e1de 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -4254,6 +4254,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -8185,6 +8189,9 @@ Keyboard_Events.xaml + + Keyboard_Modifiers.xaml + Keyboard_iOS_Theme.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml new file mode 100644 index 000000000000..27e3eb28ed83 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml.cs new file mode 100644 index 000000000000..18f101bc6b04 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml.cs @@ -0,0 +1,55 @@ +using System; +using System.Linq; +using Windows.System; +using Windows.UI.Core; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Uno.UI.Samples.Controls; + +namespace UITests.Windows_UI_Xaml_Input.Keyboard +{ + [Sample("Keyboard", IsManualTest = true)] + public sealed partial class Keyboard_Modifiers : Page + { + private DispatcherTimer _timer; + + public Keyboard_Modifiers() + { + this.InitializeComponent(); +#if HAS_UNO + _timer = new DispatcherTimer(); + _timer.Interval = TimeSpan.FromMilliseconds(100); + _timer.Tick += (_, _) => + { + var mods = PlatformHelpers.GetKeyboardModifiers(); + var modString = ""; + if (mods.HasFlag(VirtualKeyModifiers.Shift)) + { + modString += " Shift"; + } + if (mods.HasFlag(VirtualKeyModifiers.Control)) + { + modString += " Ctrl"; + } + if (mods.HasFlag(VirtualKeyModifiers.Windows)) + { + modString += " Win"; + } + if (mods.HasFlag(VirtualKeyModifiers.Menu)) + { + modString += " Menu"; + } + + if (string.IsNullOrEmpty(modString)) + { + modString = "None"; + } + statusTb.Text = $"Modifiers pressed: {modString}"; + }; + + Loaded += (_, _) => _timer.Start(); + Unloaded += (_, _) => _timer.Stop(); +#endif + } + } +}