mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
DraggableNumberBox - Focus fixes
This commit is contained in:
parent
f249f80d19
commit
aa4a740b78
@ -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">
|
||||
<UserControl.Styles>
|
||||
<Styles>
|
||||
<Style Selector="sharedControls|DraggableNumberBox:not(:focus-within)">
|
||||
<Style Selector="Panel#Container:not(:focus-within)">
|
||||
<Setter Property="Cursor" Value="{DynamicResource DragHorizontalCursor}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="sharedControls|DraggableNumberBox:focus-within Rectangle#DragCollider">
|
||||
<Style Selector="#Container:focus-within Rectangle#DragCollider">
|
||||
<Setter Property="IsHitTestVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="sharedControls|DraggableNumberBox:not(:focus-within) controls|NumberBox#NumberBox">
|
||||
<Style Selector="#Container:not(:focus-within) controls|NumberBox#NumberBox">
|
||||
<Setter Property="IsHitTestVisible" Value="False" />
|
||||
</Style>
|
||||
</Styles>
|
||||
</UserControl.Styles>
|
||||
|
||||
<Panel>
|
||||
<Panel Name="Container" Focusable="True">
|
||||
<controls:NumberBox Name="InnerNumberBox"
|
||||
AcceptsExpression="True"
|
||||
Focusable="True"
|
||||
LargeChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].LargeChange}"
|
||||
SmallChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].SmallChange}"
|
||||
Minimum="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Minimum}"
|
||||
|
||||
@ -187,9 +187,8 @@ public partial class DraggableNumberBox : UserControl
|
||||
|
||||
private void HandleKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
IInputElement? toFocus = this.GetLogicalAncestors().OfType<IInputElement>().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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user