Skip to content

Commit

Permalink
feat: Allow simulating touch input in Samples app
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Dec 5, 2024
1 parent 1f49455 commit 2a243c9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Uno.UI.Xaml.Core;
using WinUICoreServices = Uno.UI.Xaml.Core.CoreServices;
using Uno.UI;
using Uno;
#endif

namespace SampleControl.Presentation
Expand Down Expand Up @@ -448,6 +449,16 @@ public bool UseRtl
}
}

public bool SimulateTouch
{
get => WinRTFeatureConfiguration.DebugOptions.SimulateTouch;
set
{
WinRTFeatureConfiguration.DebugOptions.SimulateTouch = value;
RaisePropertyChanged();
}
}

#if HAS_UNO
public bool PreventLightDismissOnWindowDeactivated
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE92F;" />
</not_win:ToggleMenuFlyoutItem.Icon>
</not_win:ToggleMenuFlyoutItem>
<not_win:ToggleMenuFlyoutItem Text="Simulate touch" IsChecked="{Binding SimulateTouch, Mode=TwoWay}">
<not_win:ToggleMenuFlyoutItem.Icon>
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xE815;" />
</not_win:ToggleMenuFlyoutItem.Icon>
</not_win:ToggleMenuFlyoutItem>
<MenuFlyoutItem Text="Log view dump" Command="{Binding LogViewDumpCommand}" Visibility="{Binding IsDebug, Converter={StaticResource TrueToVisible}}">
<MenuFlyoutItem.Icon>
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="&#xEBD2;" />
Expand Down
8 changes: 8 additions & 0 deletions src/Uno.UWP/Devices/Input/PointerDevice.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.Serialization.Formatters;
using Uno;

namespace Windows.Devices.Input
{
Expand All @@ -10,6 +11,13 @@ public partial class PointerDevice

internal static PointerDevice For(PointerDeviceType type)
{
#if DEBUG
if (WinRTFeatureConfiguration.DebugOptions.SimulateTouch)
{
type = PointerDeviceType.Touch;
}
#endif

// We cache them as we don't implement any other properties than the PointerDeviceType
// but this is probably not really valid...
switch (type)
Expand Down
8 changes: 8 additions & 0 deletions src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ public static class StoreContext
public static bool TestMode { get; set; }
}
#endif

internal static class DebugOptions
{
/// <summary>
/// Adjusts all PointerPoint instances as if they were of type Touch.
/// </summary>
public static bool SimulateTouch { get; set; }
}
}

0 comments on commit 2a243c9

Please sign in to comment.