Skip to content

Commit

Permalink
Add input validation to text input dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Dec 5, 2024
1 parent d5c40e2 commit 2b5198f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
47 changes: 24 additions & 23 deletions YAMDCC.GUI/Dialogs/TextInputDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion YAMDCC.GUI/Dialogs/TextInputDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License along with
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Windows.Forms;

namespace YAMDCC.GUI.Dialogs
Expand All @@ -35,9 +36,16 @@ public TextInputDialog(string caption, string title = "", string text = "", bool
Text = title;
}

private void btnOK_Click(object sender, System.EventArgs e)
private void btnOK_Click(object sender, EventArgs e)
{
Result = txtInput.Text;
}

private void txtInput_TextChanged(object sender, EventArgs e)
{
// make sure text input isn't empty
// before allowing user to click "OK":
btnOK.Enabled = !string.IsNullOrEmpty(txtInput.Text);
}
}
}
3 changes: 0 additions & 3 deletions YAMDCC.GUI/Dialogs/TextInputDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,4 @@
<metadata name="btnCancel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="btnOK.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

0 comments on commit 2b5198f

Please sign in to comment.