Enter will close Text input box and Ctrl + Enter will add new line

This commit is contained in:
Jaex 2017-02-17 02:27:12 +03:00
parent d5fd63411c
commit 7fe3cc777e
3 changed files with 48 additions and 4 deletions

View file

@ -51,6 +51,7 @@ private void InitializeComponent()
this.tsmiAlignmentTop = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiAlignmentMiddle = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiAlignmentBottom = new System.Windows.Forms.ToolStripMenuItem();
this.lblTip = new System.Windows.Forms.Label();
this.flpProperties.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudTextSize)).BeginInit();
this.cmsAlignmentHorizontal.SuspendLayout();
@ -64,6 +65,7 @@ private void InitializeComponent()
this.txtInput.Name = "txtInput";
this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
this.txtInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyUp);
//
// btnTextColor
//
@ -229,11 +231,17 @@ private void InitializeComponent()
resources.ApplyResources(this.tsmiAlignmentBottom, "tsmiAlignmentBottom");
this.tsmiAlignmentBottom.Click += new System.EventHandler(this.tsmiAlignmentBottom_Click);
//
// lblTip
//
resources.ApplyResources(this.lblTip, "lblTip");
this.lblTip.Name = "lblTip";
//
// TextDrawingInputBox
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.Controls.Add(this.lblTip);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.flpProperties);
this.Controls.Add(this.txtInput);
@ -276,5 +284,6 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem tsmiAlignmentTop;
private System.Windows.Forms.ToolStripMenuItem tsmiAlignmentMiddle;
private System.Windows.Forms.ToolStripMenuItem tsmiAlignmentBottom;
private System.Windows.Forms.Label lblTip;
}
}

View file

@ -165,7 +165,15 @@ private void tsmiAlignmentBottom_Click(object sender, EventArgs e)
private void txtInput_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Control | Keys.Enter))
if (e.KeyData == Keys.Enter)
{
e.SuppressKeyPress = true;
}
}
private void txtInput_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
Close();
}

View file

@ -148,7 +148,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtInput.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="btnTextColor.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
@ -448,7 +448,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;flpProperties.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="btnOK.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
@ -475,7 +475,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;btnOK.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<metadata name="cmsAlignmentHorizontal.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
@ -537,6 +537,33 @@
<data name="&gt;&gt;cmsAlignmentVertical.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lblTip.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lblTip.Location" type="System.Drawing.Point, System.Drawing">
<value>5, 334</value>
</data>
<data name="lblTip.Size" type="System.Drawing.Size, System.Drawing">
<value>106, 13</value>
</data>
<data name="lblTip.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="lblTip.Text" xml:space="preserve">
<value>New line: Ctrl + Enter</value>
</data>
<data name="&gt;&gt;lblTip.Name" xml:space="preserve">
<value>lblTip</value>
</data>
<data name="&gt;&gt;lblTip.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lblTip.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;lblTip.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>