Browse Source

Fix #3065: Hide watermark/help text of SearchBox, if contents are changed programmatically without setting the focus to the text box first.

pull/3111/head
Siegfried Pammer 2 years ago
parent
commit
807a50cbe9
  1. 25
      ILSpy/Controls/SearchBox.cs

25
ILSpy/Controls/SearchBox.cs

@ -99,6 +99,15 @@ namespace ICSharpCode.ILSpy.Controls @@ -99,6 +99,15 @@ namespace ICSharpCode.ILSpy.Controls
timer.Stop();
timer.Interval = this.UpdateDelay;
timer.Start();
UpdateWatermarkLabel();
}
private void UpdateWatermarkLabel()
{
Label wl = (Label)GetTemplateChild("WatermarkLabel");
if (wl != null)
wl.Visibility = HasText ? Visibility.Hidden : Visibility.Visible;
}
void timer_Tick(object sender, EventArgs e)
@ -114,25 +123,13 @@ namespace ICSharpCode.ILSpy.Controls @@ -114,25 +123,13 @@ namespace ICSharpCode.ILSpy.Controls
protected override void OnLostFocus(RoutedEventArgs e)
{
if (!HasText)
{
Label wl = (Label)GetTemplateChild("WatermarkLabel");
if (wl != null)
wl.Visibility = Visibility.Visible;
}
UpdateWatermarkLabel();
base.OnLostFocus(e);
}
protected override void OnGotFocus(RoutedEventArgs e)
{
if (!HasText)
{
Label wl = (Label)GetTemplateChild("WatermarkLabel");
if (wl != null)
wl.Visibility = Visibility.Hidden;
}
UpdateWatermarkLabel();
base.OnGotFocus(e);
}

Loading…
Cancel
Save