Both login dialogs react on Enter key (moves focus).

This commit is contained in:
Milan Hanajik 2018-03-15 04:50:52 +01:00
parent 4245238112
commit e8af9418bf
5 changed files with 94 additions and 67 deletions

View File

@ -164,6 +164,14 @@ namespace TBF.Forms
}
}
private void passwordTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToInt32(e.KeyChar) == 13)
{
okButton_Click(sender, e);
}
}
private void aliasLabel_Click(object sender, EventArgs e)
{
Method++;

View File

@ -74,6 +74,7 @@ namespace TBF.Forms
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
this.passwordTextBox.Name = "passwordTextBox";
this.passwordTextBox.UseSystemPasswordChar = true;
this.passwordTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox_KeyPress);
//
// cancelButton
//
@ -96,6 +97,7 @@ namespace TBF.Forms
//
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
this.userNameTextBox.Name = "userNameTextBox";
this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress);
//
// legalizatorComboBox
//

View File

@ -31,71 +31,72 @@ namespace Users.Forms
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg));
this.aliasLabel = new System.Windows.Forms.Label();
this.passwordLabel = new System.Windows.Forms.Label();
this.passwordTextBox = new System.Windows.Forms.TextBox();
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.userNameTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// aliasLabel
//
resources.ApplyResources(this.aliasLabel, "aliasLabel");
this.aliasLabel.Name = "aliasLabel";
this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click);
//
// passwordLabel
//
resources.ApplyResources(this.passwordLabel, "passwordLabel");
this.passwordLabel.Name = "passwordLabel";
//
// passwordTextBox
//
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
this.passwordTextBox.Name = "passwordTextBox";
this.passwordTextBox.UseSystemPasswordChar = true;
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// userNameTextBox
//
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
this.userNameTextBox.Name = "userNameTextBox";
//
// LoginDlg
//
this.AcceptButton = this.okButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.Controls.Add(this.userNameTextBox);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.passwordTextBox);
this.Controls.Add(this.passwordLabel);
this.Controls.Add(this.aliasLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "LoginDlg";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Load += new System.EventHandler(this.LoginDlg_Load);
this.ResumeLayout(false);
this.PerformLayout();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg));
this.aliasLabel = new System.Windows.Forms.Label();
this.passwordLabel = new System.Windows.Forms.Label();
this.passwordTextBox = new System.Windows.Forms.TextBox();
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.userNameTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// aliasLabel
//
resources.ApplyResources(this.aliasLabel, "aliasLabel");
this.aliasLabel.Name = "aliasLabel";
this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click);
//
// passwordLabel
//
resources.ApplyResources(this.passwordLabel, "passwordLabel");
this.passwordLabel.Name = "passwordLabel";
//
// passwordTextBox
//
resources.ApplyResources(this.passwordTextBox, "passwordTextBox");
this.passwordTextBox.Name = "passwordTextBox";
this.passwordTextBox.UseSystemPasswordChar = true;
this.passwordTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox_KeyPress);
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// userNameTextBox
//
resources.ApplyResources(this.userNameTextBox, "userNameTextBox");
this.userNameTextBox.Name = "userNameTextBox";
this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress);
//
// LoginDlg
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.Controls.Add(this.userNameTextBox);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.passwordTextBox);
this.Controls.Add(this.passwordLabel);
this.Controls.Add(this.aliasLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "LoginDlg";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Load += new System.EventHandler(this.LoginDlg_Load);
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -184,5 +184,21 @@ namespace Users.Forms
aliasLabel.Text = GetAliasLabel();
}
private void userNameTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToInt32(e.KeyChar) == 13)
{
passwordTextBox.Focus();
}
}
private void passwordTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToInt32(e.KeyChar) == 13)
{
okButton_Click(sender, e);
}
}
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.829.0")]
[assembly: AssemblyFileVersion("2.18.829.0")]
[assembly: AssemblyVersion("2.18.843.0")]
[assembly: AssemblyFileVersion("2.18.843.0")]