mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-26 11:10:34 +08:00
feat(OverflowTip): implement internal text viewport metrics for TextBox and TextArea to enhance tooltip visibility handling
This commit is contained in:
@@ -198,6 +198,7 @@ public class TextBox : AvaloniaTextBox,
|
||||
private IDisposable? _feedbackStatusSubscription;
|
||||
private TextPresenter? _textPresenter;
|
||||
private IDisposable? _preeditTextSubscription;
|
||||
private IDisposable? _textViewportSubscription;
|
||||
|
||||
static TextBox()
|
||||
{
|
||||
@@ -311,6 +312,7 @@ public class TextBox : AvaloniaTextBox,
|
||||
_clearButton.Click += HandleClearButtonClicked;
|
||||
}
|
||||
SetupTextPresenterPreeditSubscription(e);
|
||||
SetupTextViewportMetrics(e);
|
||||
ConfigureEffectiveShowClearButton();
|
||||
ConfigurePlaceholderTextVisibility();
|
||||
HandleInputChanged(Text);
|
||||
@@ -329,6 +331,22 @@ public class TextBox : AvaloniaTextBox,
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupTextViewportMetrics(TemplateAppliedEventArgs e)
|
||||
{
|
||||
_textViewportSubscription?.Dispose();
|
||||
_textViewportSubscription = null;
|
||||
|
||||
var scrollViewer = e.NameScope.Find<ScrollViewer>("PART_ScrollViewer") ??
|
||||
e.NameScope.Find<ScrollViewer>("ScrollViewer");
|
||||
if (scrollViewer is null)
|
||||
{
|
||||
TextViewportMetrics.SetViewportWidth(this, null);
|
||||
return;
|
||||
}
|
||||
|
||||
_textViewportSubscription = TextViewportMetrics.PublishViewportWidth(this, scrollViewer, _textPresenter);
|
||||
}
|
||||
|
||||
private void ConfigurePlaceholderTextVisibility()
|
||||
{
|
||||
SetCurrentValue(IsPlaceholderTextVisibleProperty,
|
||||
|
||||
Reference in New Issue
Block a user