* UITextBox:解决多行输入时不能输入回车的问题

This commit is contained in:
Sunny 2021-04-17 11:20:32 +08:00
parent 74271f14ea
commit 1ecb1cf02f
4 changed files with 34 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -62,29 +62,33 @@ namespace Sunny.UI
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyData == Keys.Enter || e.KeyData == Keys.Down)
if (!Multiline)
{
if (e.KeyData == Keys.Enter)
if (e.KeyData == Keys.Enter || e.KeyData == Keys.Down)
{
EnterKeyPress?.Invoke(this, e);
if (e.KeyData == Keys.Enter)
{
EnterKeyPress?.Invoke(this, e);
}
if (EnterAsTab)
{
SendKeys.Send("{tab}");
}
e.Handled = true;
}
if (EnterAsTab)
if (e.KeyData == Keys.Up)
{
SendKeys.Send("{tab}");
if (EnterAsTab)
{
SendKeys.Send("+{TAB}");
}
e.Handled = true;
}
e.Handled = true;
}
if (e.KeyData == Keys.Up)
{
if (EnterAsTab)
{
SendKeys.Send("+{TAB}");
}
e.Handled = true;
}
if (e.Control && e.KeyCode == Keys.A)
@ -451,17 +455,20 @@ namespace Sunny.UI
protected override void OnKeyPress(KeyPressEventArgs e)
{
//以下代码 取消按下回车或esc的“叮”声
if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
if (!Multiline)
{
e.Handled = true;
}
else if (e.KeyChar == 8)
{
}
else if (!(IsValidChar(Text, e.KeyChar, SelectionStart + 1) & (e.KeyChar >= 32)))
{
e.Handled = true;
//以下代码 取消按下回车或esc的“叮”声
if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
{
e.Handled = true;
}
else if (e.KeyChar == 8)
{
}
else if (!(IsValidChar(Text, e.KeyChar, SelectionStart + 1) & (e.KeyChar >= 32)))
{
e.Handled = true;
}
}
base.OnKeyPress(e);