From fafcecf0f38d0c2cb30457fe0e951f2ba4ad7d7e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 13 Feb 2018 15:15:16 +0000 Subject: [PATCH 1/3] system dialog combines the initialDirectory and InitialFileName on Gtk. --- src/Gtk/Avalonia.Gtk3/SystemDialogs.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs index fb8af02d5d..cff376ad1f 100644 --- a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs +++ b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -79,9 +80,11 @@ namespace Avalonia.Gtk3 public Task ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) { - return ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget, + return ShowDialog(dialog.Title, ((WindowBaseImpl)parent)?.GtkWidget, dialog is OpenFileDialog ? GtkFileChooserAction.Open : GtkFileChooserAction.Save, - (dialog as OpenFileDialog)?.AllowMultiple ?? false, dialog.InitialFileName); + (dialog as OpenFileDialog)?.AllowMultiple ?? false, + Path.Combine(string.IsNullOrEmpty(dialog.InitialDirectory) ? "" : dialog.InitialDirectory, + string.IsNullOrEmpty(dialog.InitialFileName) ? "" : dialog.InitialFileName)); } public async Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) From b7de65f1aaebde38087150674cb0a80b46836ed8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 13 Feb 2018 20:39:08 +0100 Subject: [PATCH 2/3] Fix TextBox text truncation. Correctly set the value of the `TextBox`'s `HorizontalScrollBarVisibility` so that the text is not truncated. Fixes #1354 --- src/Avalonia.Controls/TextBox.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 7366ff3f91..158157766e 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -98,9 +98,19 @@ namespace Avalonia.Controls var horizontalScrollBarVisibility = Observable.CombineLatest( this.GetObservable(AcceptsReturnProperty), this.GetObservable(TextWrappingProperty), - (acceptsReturn, wrapping) => acceptsReturn && wrapping == TextWrapping.NoWrap ? - ScrollBarVisibility.Auto : ScrollBarVisibility.Disabled); - + (acceptsReturn, wrapping) => + { + if (acceptsReturn) + { + return wrapping == TextWrapping.NoWrap ? + ScrollBarVisibility.Visible : + ScrollBarVisibility.Disabled; + } + else + { + return ScrollBarVisibility.Hidden; + } + }); Bind( ScrollViewer.HorizontalScrollBarVisibilityProperty, horizontalScrollBarVisibility, From e5800c17f1405bdfdcba082c573420ee5d248776 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 13 Feb 2018 20:44:16 +0100 Subject: [PATCH 3/3] Fix TextBlock click positioning. When the click was outside the `TextPresenter`, it was not registering with the `TextBox` so the caret was being moved to the beginning. --- src/Avalonia.Controls/TextBox.cs | 49 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 158157766e..e939ace66d 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -497,37 +497,34 @@ namespace Avalonia.Controls protected override void OnPointerPressed(PointerPressedEventArgs e) { - if (e.Source == _presenter) - { - var point = e.GetPosition(_presenter); - var index = CaretIndex = _presenter.GetCaretIndex(point); - var text = Text; + var point = e.GetPosition(_presenter); + var index = CaretIndex = _presenter.GetCaretIndex(point); + var text = Text; - if (text != null) + if (text != null) + { + switch (e.ClickCount) { - switch (e.ClickCount) - { - case 1: - SelectionStart = SelectionEnd = index; - break; - case 2: - if (!StringUtils.IsStartOfWord(text, index)) - { - SelectionStart = StringUtils.PreviousWord(text, index); - } + case 1: + SelectionStart = SelectionEnd = index; + break; + case 2: + if (!StringUtils.IsStartOfWord(text, index)) + { + SelectionStart = StringUtils.PreviousWord(text, index); + } - SelectionEnd = StringUtils.NextWord(text, index); - break; - case 3: - SelectionStart = 0; - SelectionEnd = text.Length; - break; - } + SelectionEnd = StringUtils.NextWord(text, index); + break; + case 3: + SelectionStart = 0; + SelectionEnd = text.Length; + break; } - - e.Device.Capture(_presenter); - e.Handled = true; } + + e.Device.Capture(_presenter); + e.Handled = true; } protected override void OnPointerMoved(PointerEventArgs e)