From 89faa52240e1fb3b1f537d09bc5bcec050dfe983 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 19 Oct 2022 16:04:09 +0200 Subject: [PATCH 01/10] Use DragEventArgs for DragLeave event. This follows the WPF/UWP API and allows pointer information to be retrieved. --- src/Avalonia.Base/Input/DragDrop.cs | 2 +- src/Avalonia.Base/Input/DragDropDevice.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/Input/DragDrop.cs b/src/Avalonia.Base/Input/DragDrop.cs index 723d577964..fe75f678e1 100644 --- a/src/Avalonia.Base/Input/DragDrop.cs +++ b/src/Avalonia.Base/Input/DragDrop.cs @@ -13,7 +13,7 @@ namespace Avalonia.Input /// /// Event which is raised, when a drag-and-drop operation leaves the element. /// - public static readonly RoutedEvent DragLeaveEvent = RoutedEvent.Register("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop)); + public static readonly RoutedEvent DragLeaveEvent = RoutedEvent.Register("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop)); /// /// Event which is raised, when a drag-and-drop operation is updated while over the element. /// diff --git a/src/Avalonia.Base/Input/DragDropDevice.cs b/src/Avalonia.Base/Input/DragDropDevice.cs index 30a08eda17..3c91856dcd 100644 --- a/src/Avalonia.Base/Input/DragDropDevice.cs +++ b/src/Avalonia.Base/Input/DragDropDevice.cs @@ -54,7 +54,7 @@ namespace Avalonia.Input try { if (_lastTarget != null) - _lastTarget.RaiseEvent(new RoutedEventArgs(DragDrop.DragLeaveEvent)); + RaiseDragEvent(_lastTarget, inputRoot, point, DragDrop.DragLeaveEvent, effects, data, modifiers); return RaiseDragEvent(target, inputRoot, point, DragDrop.DragEnterEvent, effects, data, modifiers); } finally @@ -63,13 +63,13 @@ namespace Avalonia.Input } } - private void DragLeave(IInputElement inputRoot) + private void DragLeave(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, KeyModifiers modifiers) { if (_lastTarget == null) return; try { - _lastTarget.RaiseEvent(new RoutedEventArgs(DragDrop.DragLeaveEvent)); + RaiseDragEvent(_lastTarget, inputRoot, point, DragDrop.DragLeaveEvent, effects, data, modifiers); } finally { @@ -106,7 +106,7 @@ namespace Avalonia.Input e.Effects = DragOver(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); break; case RawDragEventType.DragLeave: - DragLeave(e.Root); + DragLeave(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); break; case RawDragEventType.Drop: e.Effects = Drop(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); From a88fdd56b97ad1b2aa9907b03546b1da292dc8cf Mon Sep 17 00:00:00 2001 From: Benedikt Date: Wed, 19 Oct 2022 16:16:12 +0200 Subject: [PATCH 02/10] Adjust Microsoft.CodeAnalysis package version --- src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj index b16ee84b4d..fe694b5730 100644 --- a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj +++ b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj @@ -19,7 +19,8 @@ - + + From 1cf220016f7bd63447b6447f31cd82256d0f548a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 20 Oct 2022 13:31:16 +0100 Subject: [PATCH 03/10] focus the root container on page load. --- src/Web/Avalonia.Web/AvaloniaView.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Web/Avalonia.Web/AvaloniaView.cs b/src/Web/Avalonia.Web/AvaloniaView.cs index 3a31679424..12d31258b5 100644 --- a/src/Web/Avalonia.Web/AvaloniaView.cs +++ b/src/Web/Avalonia.Web/AvaloniaView.cs @@ -136,6 +136,8 @@ namespace Avalonia.Web DomHelper.ObserveSize(host, null, OnSizeChanged); CanvasHelper.RequestAnimationFrame(_canvas, true); + + InputHelper.FocusElement(_containerElement); } private static RawPointerPoint ExtractRawPointerFromJSArgs(JSObject args) From 3f4034f0caf06dbdb36438666b391c0a8f62bdd6 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 20 Oct 2022 21:41:15 +0100 Subject: [PATCH 04/10] add github sponsors --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c5a719ce90..df070c35cf 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ +github: avaloniaui open_collective: avalonia From 5d8e4998c1208180395f8c2345c618c12e6bb817 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 20 Oct 2022 22:05:39 +0100 Subject: [PATCH 05/10] prevent browser touch gestures happening outside of avalonia --- src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts b/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts index 2257d56a92..783710bb3e 100644 --- a/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts +++ b/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts @@ -11,6 +11,7 @@ export class AvaloniaDOM { host.tabIndex = 0; host.oncontextmenu = function () { return false; }; host.style.overflow = "hidden"; + host.style.touchAction = "none"; // Rendering target canvas const canvas = document.createElement("canvas"); From 668296b397210192d72c0107135f0cc76f1bc1c2 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 20 Oct 2022 22:21:49 +0100 Subject: [PATCH 06/10] minify js --- src/Web/Avalonia.Web/webapp/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Web/Avalonia.Web/webapp/build.js b/src/Web/Avalonia.Web/webapp/build.js index 6b6df4c300..81f863cac7 100644 --- a/src/Web/Avalonia.Web/webapp/build.js +++ b/src/Web/Avalonia.Web/webapp/build.js @@ -5,7 +5,7 @@ require("esbuild").build({ ], outdir: "../wwwroot", bundle: true, - minify: false, + minify: true, format: "esm", target: "es2016", platform: "browser", From 9cbe262117e30a056177ebf80a87bc3c11d87d80 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 21 Oct 2022 22:05:43 +0100 Subject: [PATCH 07/10] fix copypasta --- src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts b/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts index 783710bb3e..668212964c 100644 --- a/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts +++ b/src/Web/Avalonia.Web/webapp/modules/avalonia/dom.ts @@ -24,7 +24,7 @@ export class AvaloniaDOM { // Native controls host const nativeHost = document.createElement("div"); - canvas.id = `nativeHost${randomIdPart}`; + nativeHost.id = `nativeHost${randomIdPart}`; nativeHost.classList.add("avalonia-native-host"); nativeHost.style.left = "0px"; nativeHost.style.top = "0px"; @@ -34,7 +34,7 @@ export class AvaloniaDOM { // IME const inputElement = document.createElement("input"); - canvas.id = `input${randomIdPart}`; + inputElement.id = `inputElement${randomIdPart}`; inputElement.classList.add("avalonia-input-element"); inputElement.autocapitalize = "none"; inputElement.type = "text"; From 31cef0b54ffd22d3e565aa55d4e7e006e019e8d8 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 21 Oct 2022 22:10:24 +0100 Subject: [PATCH 08/10] basic non-ime text input. --- src/Web/Avalonia.Web/AvaloniaView.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Web/Avalonia.Web/AvaloniaView.cs b/src/Web/Avalonia.Web/AvaloniaView.cs index 12d31258b5..9d7a629836 100644 --- a/src/Web/Avalonia.Web/AvaloniaView.cs +++ b/src/Web/Avalonia.Web/AvaloniaView.cs @@ -254,7 +254,14 @@ namespace Avalonia.Web private bool OnKeyDown (string code, string key, int modifier) { - return _topLevelImpl.RawKeyboardEvent(RawKeyEventType.KeyDown, code, key, (RawInputModifiers)modifier); + var handled = _topLevelImpl.RawKeyboardEvent(RawKeyEventType.KeyDown, code, key, (RawInputModifiers)modifier); + + if (!handled) + { + handled = _topLevelImpl.RawTextEvent(key); + } + + return handled; } private bool OnKeyUp(string code, string key, int modifier) From e5b745694ac22c7129c28b12a29b216770a1dafd Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 21 Oct 2022 22:23:05 +0100 Subject: [PATCH 09/10] filter modifier text input events. --- src/Web/Avalonia.Web/AvaloniaView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Web/Avalonia.Web/AvaloniaView.cs b/src/Web/Avalonia.Web/AvaloniaView.cs index 9d7a629836..296e411fa8 100644 --- a/src/Web/Avalonia.Web/AvaloniaView.cs +++ b/src/Web/Avalonia.Web/AvaloniaView.cs @@ -256,7 +256,7 @@ namespace Avalonia.Web { var handled = _topLevelImpl.RawKeyboardEvent(RawKeyEventType.KeyDown, code, key, (RawInputModifiers)modifier); - if (!handled) + if (!handled && key.Length == 1) { handled = _topLevelImpl.RawTextEvent(key); } From 1d19c37a37aa106c14002cbb88af701625f6fb34 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 22 Oct 2022 09:43:51 +0100 Subject: [PATCH 10/10] wasm prevent touch flashing android. --- src/Web/Avalonia.Web/AvaloniaView.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Web/Avalonia.Web/AvaloniaView.cs b/src/Web/Avalonia.Web/AvaloniaView.cs index 296e411fa8..098b06a0a2 100644 --- a/src/Web/Avalonia.Web/AvaloniaView.cs +++ b/src/Web/Avalonia.Web/AvaloniaView.cs @@ -77,8 +77,7 @@ namespace Avalonia.Web _topLevelImpl.SetCssCursor = (cursor) => { - InputHelper.SetCursor(_containerElement, cursor); // macOS - InputHelper.SetCursor(_canvas, cursor); // windows + InputHelper.SetCursor(_containerElement, cursor); }; _topLevel.Prepare();