diff --git a/src/OneWare.Essentials/Controls/CustomZoomBorder.cs b/src/OneWare.Essentials/Controls/CustomZoomBorder.cs index 7fd94fa5..9a4a07e1 100644 --- a/src/OneWare.Essentials/Controls/CustomZoomBorder.cs +++ b/src/OneWare.Essentials/Controls/CustomZoomBorder.cs @@ -1,10 +1,10 @@ using System.Reactive.Disposables; using System.Reactive.Linq; using Avalonia; +using Avalonia.Controls; using Avalonia.Controls.PanAndZoom; using Avalonia.Input; using Avalonia.Interactivity; -using Avalonia.ReactiveUI; using Avalonia.Threading; namespace OneWare.Essentials.Controls; @@ -12,9 +12,9 @@ namespace OneWare.Essentials.Controls; public class CustomZoomBorder : ZoomBorder { private const int KeyPanSpeed = 5; - + protected override Type StyleKeyOverride => typeof(ZoomBorder); - + private CompositeDisposable _disposables = new(); private readonly List _keysDown = []; @@ -23,11 +23,6 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); - PointerEntered += (_, _) => - { - this.Focus(); - }; - DispatcherTimer.Run(() => { if (_keysDown.Contains(Key.Down) || _keysDown.Contains(Key.S)) @@ -42,6 +37,16 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) return true; }, TimeSpan.FromMilliseconds(10)) .DisposeWith(_disposables); + + KeyDownEvent.AddClassHandler((sender, args) => + { + if(IsPointerOver) _keysDown.Add(args.Key); + }, handledEventsToo: true).DisposeWith(_disposables); + + KeyUpEvent.AddClassHandler((sender, args) => + { + _keysDown.RemoveAll(x => x == args.Key); + }, handledEventsToo: true).DisposeWith(_disposables); } protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) @@ -51,22 +56,10 @@ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e _disposables = new CompositeDisposable(); } - protected override void OnKeyDown(KeyEventArgs e) - { - _keysDown.Add(e.Key); - base.OnKeyDown(e); - } - - protected override void OnKeyUp(KeyEventArgs e) - { - _keysDown.RemoveAll(x => x == e.Key); - base.OnKeyUp(e); - } - - protected override void OnLostFocus(RoutedEventArgs e) + protected override void OnPointerExited(PointerEventArgs e) { _keysDown.Clear(); - base.OnLostFocus(e); + base.OnPointerExited(e); } public void AutoFit() diff --git a/src/OneWare.UniversalFpgaProjectSystem/Views/UniversalFpgaProjectCompileView.axaml b/src/OneWare.UniversalFpgaProjectSystem/Views/UniversalFpgaProjectCompileView.axaml index 7278e8ef..21209404 100644 --- a/src/OneWare.UniversalFpgaProjectSystem/Views/UniversalFpgaProjectCompileView.axaml +++ b/src/OneWare.UniversalFpgaProjectSystem/Views/UniversalFpgaProjectCompileView.axaml @@ -20,6 +20,8 @@ +