mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +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:sharedControls="clr-namespace:Artemis.UI.Shared.Controls"
|
||||||
xmlns:attachedProperties="clr-namespace:Artemis.UI.Shared.AttachedProperties"
|
xmlns:attachedProperties="clr-namespace:Artemis.UI.Shared.AttachedProperties"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
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>
|
<UserControl.Styles>
|
||||||
<Styles>
|
<Styles>
|
||||||
<Style Selector="sharedControls|DraggableNumberBox:not(:focus-within)">
|
<Style Selector="Panel#Container:not(:focus-within)">
|
||||||
<Setter Property="Cursor" Value="{DynamicResource DragHorizontalCursor}" />
|
<Setter Property="Cursor" Value="{DynamicResource DragHorizontalCursor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="sharedControls|DraggableNumberBox:focus-within Rectangle#DragCollider">
|
<Style Selector="#Container:focus-within Rectangle#DragCollider">
|
||||||
<Setter Property="IsHitTestVisible" Value="False" />
|
<Setter Property="IsHitTestVisible" Value="False" />
|
||||||
</Style>
|
</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" />
|
<Setter Property="IsHitTestVisible" Value="False" />
|
||||||
</Style>
|
</Style>
|
||||||
</Styles>
|
</Styles>
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
|
|
||||||
<Panel>
|
<Panel Name="Container" Focusable="True">
|
||||||
<controls:NumberBox Name="InnerNumberBox"
|
<controls:NumberBox Name="InnerNumberBox"
|
||||||
AcceptsExpression="True"
|
AcceptsExpression="True"
|
||||||
|
Focusable="True"
|
||||||
LargeChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].LargeChange}"
|
LargeChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].LargeChange}"
|
||||||
SmallChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].SmallChange}"
|
SmallChange="{CompiledBinding $parent[sharedControls:DraggableNumberBox].SmallChange}"
|
||||||
Minimum="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Minimum}"
|
Minimum="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Minimum}"
|
||||||
|
|||||||
@ -187,9 +187,8 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
|
|
||||||
private void HandleKeyUp(object? sender, KeyEventArgs e)
|
private void HandleKeyUp(object? sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
IInputElement? toFocus = this.GetLogicalAncestors().OfType<IInputElement>().LastOrDefault();
|
|
||||||
if (e.Key == Key.Enter || e.Key == Key.Escape)
|
if (e.Key == Key.Enter || e.Key == Key.Escape)
|
||||||
toFocus?.Focus();
|
Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||||
@ -217,9 +216,9 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
if (!_moved)
|
if (!_moved)
|
||||||
{
|
{
|
||||||
// Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider
|
// 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;
|
_moved = true;
|
||||||
e.Pointer.Capture(this);
|
|
||||||
DragStarted?.Invoke(this, EventArgs.Empty);
|
DragStarted?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,6 +253,7 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_moved = false;
|
_moved = false;
|
||||||
|
PseudoClasses.Remove("dragging");
|
||||||
DragFinished?.Invoke(this, EventArgs.Empty);
|
DragFinished?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user