added a "defaulttext" mode to the ng search box

This will prevent a bug when users want to perform a real search
using the same term as Language.strSearchPrompt
This commit is contained in:
David Sparer
2019-05-13 12:54:36 -05:00
parent 4fc82ab7c1
commit 027e37545b

View File

@@ -6,6 +6,7 @@ namespace mRemoteNG.UI.Controls.Base
{
public class NGSearchBox : NGTextBox
{
private bool _showDefaultText;
private PictureBox pbClear = new PictureBox();
private ToolTip btClearToolTip = new ToolTip();
@@ -36,7 +37,7 @@ namespace mRemoteNG.UI.Controls.Base
private void FocusLost(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Text))
if (_showDefaultText)
{
Text = Language.strSearchPrompt;
pbClear.Visible = false;
@@ -59,7 +60,8 @@ namespace mRemoteNG.UI.Controls.Base
private void NGSearchBox_TextChanged(object sender, EventArgs e)
{
pbClear.Visible = Text == Language.strSearchPrompt ? false : TextLength > 0;
_showDefaultText = string.IsNullOrEmpty(Text);
pbClear.Visible = !_showDefaultText && TextLength > 0;
}
}
}