Skip to content

Commit

Permalink
fix: GTK TextBox selection
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Mar 7, 2023
1 parent ebf5d8e commit 5efdac4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable

using System;
using System.Reflection.Metadata.Ecma335;
using Gtk;
using Uno.Disposables;
using Windows.UI.Xaml.Controls;
Expand Down Expand Up @@ -29,8 +30,11 @@ public override string Text

public override bool IsCompatible(TextBox textBox) => !textBox.AcceptsReturn || textBox is PasswordBox;

public override (int start, int end) GetSelectionBounds() => _entry.GetSelectionBounds(out var start, out var end) ?
(start, end) : (0, 0);
public override (int start, int end) GetSelectionBounds()
{
_entry.GetSelectionBounds(out var start, out var end);
return (start, end);
}

public override void SetSelectionBounds(int start, int end) => _entry.SelectRegion(start_pos: start, end_pos: end);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void StartEntry()
_lastPosition = new Point(-1, -1);
UpdateNativeView();
SetNativeText(textBox.Text);
InvalidateLayout();

_textBoxView!.AddToTextInputLayer(xamlRoot);
_textBoxView!.AddToTextInputLayer(xamlRoot);
InvalidateLayout();
_textBoxView.SetFocus(true);

// Selection is now handled by native control
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBoxView.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ internal void Select(int start, int length)

internal void OnForegroundChanged(Brush brush)
{
InnerText.Foreground = brush;
DisplayBlock.Foreground = brush;
_textBoxExtension?.UpdateProperties();
}

internal void OnSelectionHighlightColorChanged(SolidColorBrush brush)
{
InnerText.SelectionHighlightColor = brush;
DisplayBlock.SelectionHighlightColor = brush;
_textBoxExtension?.UpdateProperties();
}

Expand Down

0 comments on commit 5efdac4

Please sign in to comment.