Browse Source

Merge branch 'master' into refcount-scene

pull/1371/head
Steven Kirk 9 years ago
committed by GitHub
parent
commit
c8ed20d66c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 65
      src/Avalonia.Controls/TextBox.cs
  2. 7
      src/Gtk/Avalonia.Gtk3/SystemDialogs.cs

65
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,
@ -487,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)

7
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<string[]> 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<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)

Loading…
Cancel
Save