From aa4a740b78589eee53c47f1e0f5da00228bb743f Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 6 Jun 2023 19:19:43 +0200 Subject: [PATCH] DraggableNumberBox - Focus fixes --- .../Controls/DraggableNumberBox.axaml | 12 +++++++----- .../Controls/DraggableNumberBox.axaml.cs | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml index 0c571239e..5802bd188 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml @@ -6,25 +6,27 @@ xmlns:sharedControls="clr-namespace:Artemis.UI.Shared.Controls" xmlns:attachedProperties="clr-namespace:Artemis.UI.Shared.AttachedProperties" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Shared.Controls.DraggableNumberBox"> + x:Class="Artemis.UI.Shared.Controls.DraggableNumberBox" + Focusable="True"> - - - - + ().LastOrDefault(); if (e.Key == Key.Enter || e.Key == Key.Escape) - toFocus?.Focus(); + Focus(); } private void OnPointerPressed(object? sender, PointerPressedEventArgs e) @@ -217,9 +216,9 @@ public partial class DraggableNumberBox : UserControl if (!_moved) { // Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider - (Parent as IInputElement)?.Focus(); + PseudoClasses.Add("dragging"); + Focus(); _moved = true; - e.Pointer.Capture(this); DragStarted?.Invoke(this, EventArgs.Empty); } @@ -254,6 +253,7 @@ public partial class DraggableNumberBox : UserControl else { _moved = false; + PseudoClasses.Remove("dragging"); DragFinished?.Invoke(this, EventArgs.Empty); }