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

Deadpikle 5 years ago
parent
commit
6c29598071
2 changed files with 3 additions and 2 deletions
  1. 2 1
      src/Avalonia.Controls/TextBox.cs
  2. 1 1
      src/Avalonia.Themes.Default/TextBox.xaml

+ 2 - 1
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);

+ 1 - 1
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">