diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index ed6e16421..a36fa3fac 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -43,9 +43,9 @@
-
-
-
+
+
+
diff --git a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj
index 9607a10d8..21c5abd88 100644
--- a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj
+++ b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj
@@ -16,11 +16,11 @@
-
-
+
+
-
-
+
+
diff --git a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj
index e674a2ad6..9e2fc0938 100644
--- a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj
+++ b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj
@@ -15,11 +15,11 @@
-
-
+
+
-
-
+
+
diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
index 0c4439627..36817bd6b 100644
--- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
+++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
@@ -10,17 +10,17 @@
-
+
-
-
-
+
+
+
-
-
+
+
-
+
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">
-
-
-
-
+
{
UpdateDisplayTextBox();
@@ -78,7 +79,19 @@ public partial class HotkeyBox : UserControl
private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e)
{
if (e.Modifiers == KeyboardModifierKey.None)
- Dispatcher.UIThread.Post(() => FocusManager.Instance?.Focus(null));
+ Dispatcher.UIThread.Post(ClearFocus);
+ }
+
+ private void ClearFocus()
+ {
+ InputElement? element = this.FindAncestorOfType();
+ if (element == null)
+ return;
+
+ bool wasFocusable = element.Focusable;
+ element.Focusable = true;
+ element.Focus();
+ element.Focusable = wasFocusable;
}
private void UpdateDisplayTextBox()
@@ -96,7 +109,7 @@ public partial class HotkeyBox : UserControl
private void Button_OnClick(object? sender, RoutedEventArgs e)
{
Hotkey = null;
- FocusManager.Instance?.Focus(null);
+ ClearFocus();
UpdateDisplayTextBox();
}
diff --git a/src/Artemis.UI.Shared/ReactiveAppWindow.cs b/src/Artemis.UI.Shared/ReactiveAppWindow.cs
index 58f4ad820..a751f4ee6 100644
--- a/src/Artemis.UI.Shared/ReactiveAppWindow.cs
+++ b/src/Artemis.UI.Shared/ReactiveAppWindow.cs
@@ -48,7 +48,7 @@ public class ReactiveAppWindow : AppWindow, IViewFor whe
return;
TransparencyBackgroundFallback = Brushes.Transparent;
- TransparencyLevelHint = WindowTransparencyLevel.Mica;
+ TransparencyLevelHint = new[] {WindowTransparencyLevel.Mica};
TryEnableMicaEffect();
}
diff --git a/src/Artemis.UI.Shared/Utilities.cs b/src/Artemis.UI.Shared/Utilities.cs
index cb2d58992..832e07b75 100644
--- a/src/Artemis.UI.Shared/Utilities.cs
+++ b/src/Artemis.UI.Shared/Utilities.cs
@@ -1,7 +1,5 @@
using System;
-using System.ComponentModel;
using System.Reactive.Linq;
-using System.Reactive.Subjects;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Input.Platform;
@@ -14,12 +12,9 @@ namespace Artemis.UI.Shared;
///
public static class UI
{
- private static readonly BehaviorSubject KeyBindingsEnabledSubject = new(false);
-
static UI()
{
- if (KeyboardDevice.Instance != null)
- KeyboardDevice.Instance.PropertyChanged += InstanceOnPropertyChanged;
+ KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox).StartWith(true);
}
///
@@ -35,15 +30,5 @@ public static class UI
///
/// Gets a boolean indicating whether hotkeys are to be disabled.
///
- public static IObservable KeyBindingsEnabled { get; } = KeyBindingsEnabledSubject.AsObservable();
-
- private static void InstanceOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
- {
- if (KeyboardDevice.Instance == null || e.PropertyName != nameof(KeyboardDevice.FocusedElement))
- return;
-
- bool enabled = KeyboardDevice.Instance.FocusedElement is not TextBox;
- if (KeyBindingsEnabledSubject.Value != enabled)
- KeyBindingsEnabledSubject.OnNext(enabled);
- }
+ public static IObservable KeyBindingsEnabled { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj
index bdea0536c..3910a5e65 100644
--- a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj
+++ b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj
@@ -21,12 +21,12 @@
-
-
+
+
-
-
-
+
+
+
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index ce2eaaf18..8a469b41c 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -15,25 +15,25 @@
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
diff --git a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs
index bd3845bfa..b23346427 100644
--- a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs
+++ b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs
@@ -103,8 +103,9 @@ public class SimpleContextDragBehavior : Behavior
private void AssociatedObject_PointerPressed(object? sender, PointerPressedEventArgs e)
{
+ IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager;
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
- if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox)
+ if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox)
return;
if (e.Source is not Control control || AssociatedObject?.DataContext != control.DataContext)
return;
@@ -130,8 +131,9 @@ public class SimpleContextDragBehavior : Behavior
private async void AssociatedObject_PointerMoved(object? sender, PointerEventArgs e)
{
+ IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager;
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
- if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox)
+ if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox)
return;
if (_triggerEvent is null)
diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs
index 1ef4838a8..9063787d5 100644
--- a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs
+++ b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs
@@ -1,5 +1,4 @@
using Avalonia.Input;
-using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
@@ -16,6 +15,6 @@ public partial class StringPropertyInputView : ReactiveUserControl
-