mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Upgrade Avalonia to 11 rc1
This commit is contained in:
1 parent
70b6035b0d
commit
f249f80d19
16 files changed
+64
-95
No files matched your search
@@ -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;
|
||||
/// </summary>
|
||||
public static class UI
|
||||
{
|
||||
private static readonly BehaviorSubject<bool> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,15 +30,5 @@ public static class UI
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether hotkeys are to be disabled.
|
||||
/// </summary>
|
||||
public static IObservable<bool> 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<bool> KeyBindingsEnabled { get; }
|
||||
}
|
||||
Reference in new issue
Block a user