UI - Rename folders and layers in a dialog to avoid hotkey issues

UI - Fixed renaming an effect executing twice, requiring two undo-actions to undo it
UI - Always disable editor hotkeys when typing in any input
This commit is contained in:
Robert committed 2023-04-19 16:03:57 +02:00
1 parent 0b5866a2b8
commit 192b4f0df2
20 files changed
+166 -147

No files matched your search

+37 -2
View File
@@ -1,8 +1,43 @@
using DryIoc;
using System;
using System.ComponentModel;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Avalonia.Controls;
using Avalonia.Input;
using IContainer = DryIoc.IContainer;
namespace Artemis.UI.Shared;
internal static class UI
/// <summary>
/// Static UI helpers.
/// </summary>
public static class UI
{
private static readonly BehaviorSubject<bool> KeyBindingsEnabledSubject = new(false);
static UI()
{
if (KeyboardDevice.Instance != null)
KeyboardDevice.Instance.PropertyChanged += InstanceOnPropertyChanged;
}
/// <summary>
/// Gets the current IoC locator.
/// </summary>
public static IContainer Locator { get; set; } = null!;
/// <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);
}
}