Redirect focus to ACB
MODIFY
WalletWasabi.Fluent/Behaviors/TagsBoxAutoCompleteBoxBehavior.cs
WalletWasabi.Fluent/Behaviors/TagsBoxAutoCompleteBoxBehavior.cs
@@ -25,6 +25,9 @@ namespace WalletWasabi.Fluent.Behaviors
public static readonly StyledProperty<Action> BackspaceAndEmptyTextActionProperty =
AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, Action>(nameof(BackspaceAndEmptyTextAction));
+ public static readonly StyledProperty<Action> GrabFocusActionProperty =
+ AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, Action>(nameof(GrabFocusActionProperty));
+
private IDisposable? _disposable;
private bool _bs1;
@@ -54,6 +57,13 @@ namespace WalletWasabi.Fluent.Behaviors
set => SetValue(BackspaceAndEmptyTextActionProperty, value);
}
+
+ public Action GrabFocusAction
+ {
+ get => GetValue(GrabFocusActionProperty);
+ set => SetValue(GrabFocusActionProperty, value);
+ }
+
protected override void OnAttached()
{
if (AssociatedObject is null) return;
@@ -61,20 +71,26 @@ namespace WalletWasabi.Fluent.Behaviors
AssociatedObject.KeyUp += OnKeyUp;
AssociatedObject.TextChanged += OnTextChanged;
AssociatedObject.DropDownClosed += OnDropDownClosed;
+ GrabFocusAction += DoGrabFocus;
_disposable =
AssociatedObject.AddDisposableHandler(InputElement.TextInputEvent, OnTextInput,
RoutingStrategies.Tunnel);
- Dispatcher.UIThread.InvokeAsync(() =>
- {
// Refocus because the old control is destroyed
// when the tag list changes.
- AssociatedObject.Focus();
- });
+ DoGrabFocus();
base.OnAttached();
}
+ private void DoGrabFocus()
+ {
+ Dispatcher.UIThread.Post(() =>
+ {
+ if(!AssociatedObject?.IsFocused ?? false) AssociatedObject?.Focus();
+ });
+ }
+
private void OnTextInput(object? sender, TextInputEventArgs e)
{
if (AssociatedObject is null) return;
@@ -168,6 +184,8 @@ namespace WalletWasabi.Fluent.Behaviors
AssociatedObject.DropDownClosed -= OnDropDownClosed;
AssociatedObject.KeyUp -= OnKeyUp;
AssociatedObject.TextChanged -= OnTextChanged;
+ GrabFocusAction -= DoGrabFocus;
+
_disposable?.Dispose();
BackspaceLogicClear();

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml
WalletWasabi.Fluent/Controls/TagsBox.xaml
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
- xmlns:vmt="clr-namespace:WalletWasabi.Fluent.ViewModels.TagsBox">
+ xmlns:vmt="clr-namespace:WalletWasabi.Fluent.ViewModels.TagsBox"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
+ xmlns:iac="clr-namespace:Avalonia.Xaml.Interactions.Custom;assembly=Avalonia.Xaml.Interactions.Custom">
<Style Selector="c|TagsBox">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
+ <Setter Property="Cursor" Value="IBeam" />
<Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="Template">
<ControlTemplate>
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
MinWidth="{TemplateBinding MinWidth}"
- MinHeight="{TemplateBinding MinHeight}" />
- <Border
- Margin="{TemplateBinding BorderThickness}">
+ MinHeight="{TemplateBinding MinHeight}"
+ Focusable="False" />
+ <Panel Name="PART_RootPanel" Background="Transparent">
+ <i:Interaction.Behaviors>
+ <ia:EventTriggerBehavior EventName="PointerReleased"
+ SourceObject="{Binding #PART_RootPanel}">
+ <ia:InvokeCommandAction Command="{Binding GrabFocusCommand}" />
+ </ia:EventTriggerBehavior>
+ </i:Interaction.Behaviors>
+ </Panel>
+ <Panel Margin="{TemplateBinding BorderThickness}">
<Grid ColumnDefinitions="Auto,*,Auto">
- <DockPanel x:Name="PART_InnerDockPanel" Grid.Column="1" Grid.ColumnSpan="1"
+ <DockPanel Background="{x:Null}" x:Name="PART_InnerDockPanel" Grid.Column="1"
Margin="{TemplateBinding Padding}">
<DataValidationErrors>
- <ScrollViewer
+ <ScrollViewer Background="{x:Null}"
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<Panel>
</DataValidationErrors>
</DockPanel>
</Grid>
- </Border>
+ </Panel>
</Panel>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="c|TagsBox AutoCompleteBox">
+ <Setter Property="Background" Value="{x:Null}" />
<Setter Property="Padding" Value="3,10,0, 10" />
<Setter Property="Margin" Value="0" />
</Style>

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
@@ -6,6 +6,5 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public class TagsBox : ContentControl
{
-
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/TagsBox/TagInputViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagInputViewModel.cs
@@ -13,6 +13,7 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
private Action _backspaceAndEmptyTextAction;
private Action<string> _commitTextAction;
+ private Action _grabFocusAction;
public TagInputViewModel(TagsBoxViewModel parent)
{
@@ -30,8 +31,6 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
public IEnumerable Suggestions => _suggestions.Value;
public bool RestrictInputToSuggestions => _restrictInputToSuggestions.Value;
-
-
public Action<string> CommitTextAction
{
get => _commitTextAction;
@@ -44,6 +43,12 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
set => this.RaiseAndSetIfChanged(ref _backspaceAndEmptyTextAction, value);
}
+ public Action GrabFocusAction
+ {
+ get => _grabFocusAction;
+ set => this.RaiseAndSetIfChanged(ref _grabFocusAction, value);
+ }
+
private void OnBackspaceAndEmptyTextAction()
{
_parent.RemoveTag();

MODIFY
WalletWasabi.Fluent/ViewModels/TagsBox/TagsBoxViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagsBoxViewModel.cs
@@ -9,6 +9,7 @@ using ReactiveUI;
using WalletWasabi.Gui.ViewModels;
using ReactiveUI;
using System.Collections.ObjectModel;
+using System.Reactive;
using System.Reactive.Linq;
using DynamicData;
using DynamicData.Binding;
@@ -18,8 +19,6 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
public class TagsBoxViewModel : ViewModelBase
{
private readonly ReadOnlyObservableCollection<object> _combinedContent;
-
-
private IEnumerable _suggestions;
private ObservableCollection<TagViewModel> _tags;
@@ -41,8 +40,13 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
.ObserveOn(RxApp.MainThreadScheduler)
.Bind(out _combinedContent)
.AsObservableList();
- }
+ GrabFocusCommand = ReactiveCommand.Create((object x) =>
+ {
+ TagInput?.GrabFocusAction?.Invoke();
+ return new object();
+ });
+ }
public ReadOnlyObservableCollection<object> CombinedContent => _combinedContent;
@@ -66,6 +70,8 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
set => this.RaiseAndSetIfChanged(ref _tags, value);
}
+ public ReactiveCommand<object, object> GrabFocusCommand { get; }
+
public void AddTag(string tagString)
{
Tags.Add(new TagViewModel(this, tagString));

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
</DockPanel>
</Panel>
</SplitView>
- <c:Dialog DataContext="{Binding CurrentDialog}" Content="{Binding }" IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}" />
+ <!-- <c:Dialog DataContext="{Binding CurrentDialog}" Content="{Binding }" IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}" /> -->
</Panel>
</UserControl>

MODIFY
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
Margin="44 0">
<Grid RowDefinitions="Auto,20,Auto" VerticalAlignment="Top" >
<TextBlock Classes="h7 bold" Text="Type in your recovery words here:"/>
- <c:TagsBox Grid.Row="2" x:DataType="{x:Type vm:RecoveryPageViewModel}"
- DataContext="{CompiledBinding RecoveryWordsTagsBox}"
+ <c:TagsBox Grid.Row="2"
+ DataContext="{Binding RecoveryWordsTagsBox}"
MinHeight="60"
MaxHeight="120"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

MODIFY
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
<behaviors:TagsBoxAutoCompleteBoxBehavior
RestrictInputToSuggestions="{CompiledBinding RestrictInputToSuggestions}"
Suggestions="{CompiledBinding Suggestions}"
+ GrabFocusAction="{CompiledBinding GrabFocusAction, Mode=OneWayToSource}"
CommitTextAction="{CompiledBinding CommitTextAction}"
BackspaceAndEmptyTextAction="{CompiledBinding BackspaceAndEmptyTextAction}" />
</i:Interaction.Behaviors>

Redirect focus to ACB