Browse Source
Merge branch 'master' into bench-style-attach
pull/3560/head
Dariusz Komosiński
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
58 additions and
6 deletions
-
src/Avalonia.Controls/TextBox.cs
-
src/Avalonia.Controls/Window.cs
-
tests/Avalonia.Controls.UnitTests/WindowTests.cs
|
|
|
@ -316,8 +316,7 @@ namespace Avalonia.Controls |
|
|
|
!AcceptsReturn && |
|
|
|
Text?.Length > 0) |
|
|
|
{ |
|
|
|
SelectionStart = 0; |
|
|
|
SelectionEnd = Text.Length; |
|
|
|
SelectAll(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
@ -673,8 +672,7 @@ namespace Avalonia.Controls |
|
|
|
SelectionEnd = StringUtils.NextWord(text, index); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
SelectionStart = 0; |
|
|
|
SelectionEnd = text.Length; |
|
|
|
SelectAll(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -896,7 +894,10 @@ namespace Avalonia.Controls |
|
|
|
CaretIndex = caretIndex; |
|
|
|
} |
|
|
|
|
|
|
|
private void SelectAll() |
|
|
|
/// <summary>
|
|
|
|
/// Select all text in the TextBox
|
|
|
|
/// </summary>
|
|
|
|
public void SelectAll() |
|
|
|
{ |
|
|
|
SelectionStart = 0; |
|
|
|
SelectionEnd = Text?.Length ?? 0; |
|
|
|
|
|
|
|
@ -529,7 +529,7 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
var sizeToContent = SizeToContent; |
|
|
|
var clientSize = ClientSize; |
|
|
|
Size constraint = clientSize; |
|
|
|
var constraint = availableSize; |
|
|
|
|
|
|
|
if ((sizeToContent & SizeToContent.Width) != 0) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -341,11 +341,62 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Child_Should_Be_Measured_With_Width_And_Height_If_SizeToContent_Is_Manual() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var child = new ChildControl(); |
|
|
|
var target = new Window |
|
|
|
{ |
|
|
|
Width = 100, |
|
|
|
Height = 50, |
|
|
|
SizeToContent = SizeToContent.Manual, |
|
|
|
Content = child |
|
|
|
}; |
|
|
|
|
|
|
|
target.Show(); |
|
|
|
|
|
|
|
Assert.Equal(new Size(100, 50), child.MeasureSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Child_Should_Be_Measured_With_Infinity_If_SizeToContent_Is_WidthAndHeight() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var child = new ChildControl(); |
|
|
|
var target = new Window |
|
|
|
{ |
|
|
|
Width = 100, |
|
|
|
Height = 50, |
|
|
|
SizeToContent = SizeToContent.WidthAndHeight, |
|
|
|
Content = child |
|
|
|
}; |
|
|
|
|
|
|
|
target.Show(); |
|
|
|
|
|
|
|
Assert.Equal(Size.Infinity, child.MeasureSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private IWindowImpl CreateImpl(Mock<IRenderer> renderer) |
|
|
|
{ |
|
|
|
return Mock.Of<IWindowImpl>(x => |
|
|
|
x.Scaling == 1 && |
|
|
|
x.CreateRenderer(It.IsAny<IRenderRoot>()) == renderer.Object); |
|
|
|
} |
|
|
|
|
|
|
|
private class ChildControl : Control |
|
|
|
{ |
|
|
|
public Size MeasureSize { get; private set; } |
|
|
|
|
|
|
|
protected override Size MeasureOverride(Size availableSize) |
|
|
|
{ |
|
|
|
MeasureSize = availableSize; |
|
|
|
return base.MeasureOverride(availableSize); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|