Skip to content

Commit

Permalink
Merge pull request #19002 from unoplatform/dev/mazi/simulate-touch
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund authored Dec 6, 2024
2 parents 7801e28 + 1c58db9 commit 2f3ff92
Show file tree
Hide file tree
Showing 4 changed files with 40 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 @@ -449,6 +450,22 @@ public bool UseRtl
}

#if HAS_UNO
public bool SimulateTouch
{
#if DEBUG
get => WinRTFeatureConfiguration.DebugOptions.SimulateTouch;
#else
get => false;
#endif
set
{
#if DEBUG
WinRTFeatureConfiguration.DebugOptions.SimulateTouch = value;
RaisePropertyChanged();
#endif
}
}

public bool PreventLightDismissOnWindowDeactivated
{
get => FeatureConfiguration.Popup.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
10 changes: 10 additions & 0 deletions src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ public static class StoreContext
public static bool TestMode { get; set; }
}
#endif

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

0 comments on commit 2f3ff92

Please sign in to comment.