Skip to content

Commit

Permalink
perf: Add OnNativePointerEvent export
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed May 11, 2023
1 parent b42f301 commit bbdcc2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
using Windows.UI.Input;
#endif

#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.JavaScript;
#endif

namespace Windows.UI.Xaml;

public partial class UIElement : DependencyObject
Expand Down Expand Up @@ -133,6 +137,9 @@ partial void RemovePointerHandler(RoutedEvent routedEvent, int remainingHandlers

#region Native event dispatch
[EditorBrowsable(EditorBrowsableState.Never)]
#if NET7_0_OR_GREATER
[JSExport]
#endif
public static void OnNativePointerEvent()
{
var stopPropagation = false;
Expand Down
12 changes: 10 additions & 2 deletions src/Uno.UI/ts/Windows/UI/Xaml/UIElement.Pointers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@

public static setPointerEventArgs(pArgs: number): void {
if (!UIElement._dispatchPointerEventMethod) {
UIElement._dispatchPointerEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Windows.UI.Xaml.UIElement:OnNativePointerEvent");
if ((<any>globalThis).DotnetExports !== undefined) {
UIElement._dispatchPointerEventMethod = (<any>globalThis).DotnetExports.UnoUI.Windows.UI.Xaml.UIElement.OnNativePointerEvent;
} else {
UIElement._dispatchPointerEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Windows.UI.Xaml.UIElement:OnNativePointerEvent");
}
}
UIElement._dispatchPointerEventArgs = pArgs;
}

public static setPointerEventResult(pArgs: number): void {
if (!UIElement._dispatchPointerEventMethod) {
UIElement._dispatchPointerEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Windows.UI.Xaml.UIElement:OnNativePointerEvent");
if ((<any>globalThis).DotnetExports !== undefined) {
UIElement._dispatchPointerEventMethod = (<any>globalThis).DotnetExports.UnoUI.Windows.UI.Xaml.UIElement.OnNativePointerEvent;
} else {
UIElement._dispatchPointerEventMethod = (<any>Module).mono_bind_static_method("[Uno.UI] Windows.UI.Xaml.UIElement:OnNativePointerEvent");
}
}
UIElement._dispatchPointerEventResult = pArgs;
}
Expand Down

0 comments on commit bbdcc2b

Please sign in to comment.