Replace recursive set, fix mac deadlock
MODIFY
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
@@ -149,16 +149,26 @@ namespace WalletWasabi.Gui.Behaviors
}
}),
AssociatedObject
- .WhenAnyValue(x => x.Text)
- .Throttle(TimeSpan.FromMilliseconds(200)) // Do not remove this we need to make sure we are running on a separate Task.
+ .GetObservable(InputElement.KeyUpEvent)
+ .Throttle(TimeSpan.FromMilliseconds(500)) // Do not remove this we need to make sure we are running on a separate Task.
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(text =>
+ .Subscribe(_ =>
{
- ProcessText(text);
+ ProcessText(AssociatedObject.Text);
MyTextBoxState = TextBoxState.NormalTextBoxOperation;
})
};
+ if (AssociatedObject is ExtendedTextBox extendedTextBox)
+ {
+ Disposables.Add(extendedTextBox.TextPasted
+ .Subscribe(text =>
+ {
+ ProcessText(text);
+ MyTextBoxState = TextBoxState.NormalTextBoxOperation;
+ }));
+ }
+
Disposables.Add(
AssociatedObject.GetObservable(InputElement.PointerReleasedEvent).Subscribe(async pointer =>
{

MODIFY
WalletWasabi.Gui/Controls/ExtendedTextBox.cs
WalletWasabi.Gui/Controls/ExtendedTextBox.cs
@@ -12,6 +12,7 @@ using ReactiveUI;
using System;
using System.Reactive;
using System.Reactive.Linq;
+using System.Reactive.Subjects;
using System.Threading.Tasks;
namespace WalletWasabi.Gui.Controls
@@ -20,6 +21,16 @@ namespace WalletWasabi.Gui.Controls
{
private MenuItem _pasteItem = null;
+ private Subject<string> _textPasted = new Subject<string>();
+
+ public IObservable<string> TextPasted
+ {
+ get
+ {
+ return _textPasted.AsObservable();
+ }
+ }
+
public ExtendedTextBox()
{
CopyCommand = ReactiveCommand.CreateFromTask(async () =>
@@ -29,7 +40,16 @@ namespace WalletWasabi.Gui.Controls
PasteCommand = ReactiveCommand.CreateFromTask(async () =>
{
- await PasteAsync();
+ try
+ {
+ var pastedText = await PasteAsync();
+
+ _textPasted.OnNext(pastedText);
+ }
+ catch (Exception exception)
+ {
+ _textPasted.OnError(exception);
+ }
});
CopyCommand.ThrownExceptions.Subscribe(Logging.Logger.LogWarning<ExtendedTextBox>);
@@ -68,16 +88,17 @@ namespace WalletWasabi.Gui.Controls
private ReactiveCommand<Unit, Unit> CopyCommand { get; }
private ReactiveCommand<Unit, Unit> PasteCommand { get; }
- private async Task PasteAsync()
+ private async Task<string> PasteAsync()
{
var text = await Application.Current.Clipboard.GetTextAsync();
if (text is null)
{
- return;
+ return null;
}
OnTextInput(new TextInputEventArgs { Text = text });
+ return text;
}
protected string GetSelection()

Replace recursive set, fix mac deadlock