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( var horizontalScrollBarVisibility = Observable.CombineLatest(
this.GetObservable(AcceptsReturnProperty), this.GetObservable(AcceptsReturnProperty),
this.GetObservable(TextWrappingProperty), this.GetObservable(TextWrappingProperty),
(acceptsReturn, wrapping) => acceptsReturn && wrapping == TextWrapping.NoWrap ? (acceptsReturn, wrapping) =>
ScrollBarVisibility.Auto : ScrollBarVisibility.Disabled); {
if (acceptsReturn)
{
return wrapping == TextWrapping.NoWrap ?
ScrollBarVisibility.Visible :
ScrollBarVisibility.Disabled;
}
else
{
return ScrollBarVisibility.Hidden;
}
});
Bind( Bind(
ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollViewer.HorizontalScrollBarVisibilityProperty,
horizontalScrollBarVisibility, horizontalScrollBarVisibility,
@ -487,37 +497,34 @@ namespace Avalonia.Controls
protected override void OnPointerPressed(PointerPressedEventArgs e) protected override void OnPointerPressed(PointerPressedEventArgs e)
{ {
if (e.Source == _presenter) var point = e.GetPosition(_presenter);
{ var index = CaretIndex = _presenter.GetCaretIndex(point);
var point = e.GetPosition(_presenter); var text = Text;
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;
case 1: break;
SelectionStart = SelectionEnd = index; case 2:
break; if (!StringUtils.IsStartOfWord(text, index))
case 2: {
if (!StringUtils.IsStartOfWord(text, index)) SelectionStart = StringUtils.PreviousWord(text, index);
{ }
SelectionStart = StringUtils.PreviousWord(text, index);
}
SelectionEnd = StringUtils.NextWord(text, index); SelectionEnd = StringUtils.NextWord(text, index);
break; break;
case 3: case 3:
SelectionStart = 0; SelectionStart = 0;
SelectionEnd = text.Length; SelectionEnd = text.Length;
break; break;
}
} }
e.Device.Capture(_presenter);
e.Handled = true;
} }
e.Device.Capture(_presenter);
e.Handled = true;
} }
protected override void OnPointerMoved(PointerEventArgs e) protected override void OnPointerMoved(PointerEventArgs e)

7
src/Gtk/Avalonia.Gtk3/SystemDialogs.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -79,9 +80,11 @@ namespace Avalonia.Gtk3
public Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) 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 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) public async Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)

Loading…
Cancel
Save