Browse Source

Fix clicking TextBox border moving to end

Twofold fix:
1) Cursor doesn't show IBeam when not in DockPanel
2) If you do click the border, it just focuses the text box -- it does not move the selection
pull/3677/head
Deadpikle 6 years ago
parent
commit
6c29598071
  1. 3
      src/Avalonia.Controls/TextBox.cs
  2. 2
      src/Avalonia.Themes.Default/TextBox.xaml

3
src/Avalonia.Controls/TextBox.cs

@ -701,7 +701,8 @@ namespace Avalonia.Controls
{
var text = Text;
if (text != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
var clickInfo = e.GetCurrentPoint(this);
if (text != null && clickInfo.Properties.IsLeftButtonPressed && !(clickInfo.Pointer?.Captured is Border))
{
var point = e.GetPosition(_presenter);
var index = CaretIndex = _presenter.GetCaretIndex(point);

2
src/Avalonia.Themes.Default/TextBox.xaml

@ -69,7 +69,7 @@
<Style Selector="TextBox:error /template/ Border#border">
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}"/>
</Style>
<Style Selector="TextBox">
<Style Selector="TextBox /template/ DockPanel">
<Setter Property="Cursor" Value="IBeam" />
</Style>
<Style Selector="TextBox:disabled /template/ Border#border">

Loading…
Cancel
Save