-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18702 from ramezgerges/wasm_modifier_key_tracking
- Loading branch information
Showing
5 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Page | ||
x:Class="UITests.Windows_UI_Xaml_Input.Keyboard.Keyboard_Modifiers" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Input.Keyboard" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<StackPanel> | ||
<TextBlock> | ||
<Run Text="Repro steps (only Uno targets, not WinUI):" /> | ||
<LineBreak /> | ||
<Run Text="1. You should see 'Modifiers pressed: None' below." /> | ||
<LineBreak /> | ||
<Run Text="2. Press the Shift key. You should see the modifier status below change to reflect that shift is pressed" /> | ||
<LineBreak /> | ||
<Run Text="3. Release the Shift key. You should see tha modifier status below go back to 'Modifiers pressed: None'" /> | ||
</TextBlock> | ||
<TextBlock x:Name="statusTb" Text="Modifiers pressed: None" /> | ||
</StackPanel> | ||
</Page> |
57 changes: 57 additions & 0 deletions
57
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Input/Keyboard/Keyboard_Modifiers.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 | ||
{ | ||
#if HAS_UNO | ||
private DispatcherTimer _timer; | ||
#endif | ||
|
||
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters