Display "Review Coins" while LeftAlt is held
ADD
WalletWasabi.Fluent/Behaviors/HoldKeyBehavior.cs
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using Avalonia;
+using Avalonia.Data;
+using Avalonia.Input;
+using Avalonia.VisualTree;
+using ReactiveUI;
+using WalletWasabi.Fluent.Extensions;
+
+namespace WalletWasabi.Fluent.Behaviors;
+
+public class HoldKeyBehavior : AttachedToVisualTreeBehavior<InputElement>
+{
+ public static readonly StyledProperty<Key?> KeyProperty =
+ AvaloniaProperty.Register<HoldKeyBehavior, Key?>(nameof(Key));
+
+ public static readonly StyledProperty<bool> IsKeyPressedProperty = AvaloniaProperty.Register<HoldKeyBehavior, bool>(nameof(IsKeyPressed), defaultBindingMode: BindingMode.TwoWay);
+
+ public Key? Key
+ {
+ get => GetValue(KeyProperty);
+ set => SetValue(KeyProperty, value);
+ }
+
+ public bool IsKeyPressed
+ {
+ get => GetValue(IsKeyPressedProperty);
+ set => SetValue(IsKeyPressedProperty, value);
+ }
+
+ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)
+ {
+ if (AssociatedObject.GetVisualRoot() is not IInputElement ie)
+ {
+ return;
+ }
+
+ var ups = ie.OnEvent(InputElement.KeyDownEvent);
+ var downs = ie.OnEvent(InputElement.KeyUpEvent);
+
+ var pressedKeys = ups
+ .Select(x => new { x.EventArgs.Key, IsPressed = true })
+ .Merge(downs.Select(x => new { x.EventArgs.Key, IsPressed = false }));
+
+ var targetKeys = this.WhenAnyValue(x => x.Key);
+
+ pressedKeys
+ .WithLatestFrom(targetKeys, (pressedKey, targetKey) => new { pressedKey.IsPressed, TargetKey = pressedKey.Key, PressedKey = targetKey })
+ .Where(x => x.PressedKey == x.TargetKey)
+ .Select(x => x.IsPressed)
+ .StartWith(false)
+ .Do(b => IsKeyPressed = b)
+ .Subscribe()
+ .DisposeWith(disposable);
+ }
+}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -137,8 +137,6 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
ChangePocketCommand = ReactiveCommand.CreateFromTask(OnChangePocketsAsync);
ChangeCoinsCommand = ReactiveCommand.CreateFromTask(OnChangeCoinsAsync);
-
- EnableCoinControlCommand = ReactiveCommand.Create(() => IsCoinControlVisible = true);
}
public TransactionSummaryViewModel CurrentTransactionSummary { get; }
@@ -158,7 +156,6 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
public ICommand ChangeCoinsCommand { get; }
public ICommand UndoCommand { get; }
- public ICommand EnableCoinControlCommand { get; }
private async Task OnExportPsbtAsync()
{

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
ScrollViewer.VerticalScrollBarVisibility="Auto">
<i:Interaction.Behaviors>
- <behaviors:ExecuteCommandOnKeyDownBehavior Key="LeftAlt" Command="{Binding EnableCoinControlCommand}" />
+ <behaviors:HoldKeyBehavior Key="LeftAlt" IsKeyPressed="{Binding IsCoinControlVisible}" />
</i:Interaction.Behaviors>
<c:ContentArea.Title>

Display "Review Coins" while LeftAlt is held