feat. 回车后自动加载神秘代码对应文本

This commit is contained in:
lhhxxxxx
2022-08-24 00:24:10 +08:00
parent 788cf78fca
commit 4d5f24e8e1
2 changed files with 23 additions and 0 deletions

View File

@@ -479,5 +479,27 @@ namespace MeoAsstGui
FocusManager.SetFocusedElement(scope, element);
Keyboard.ClearFocus();
}
/// <summary>
/// 回车键点击后移除界面中元素焦点
/// </summary>
/// <param name="sender">点击事件发送者</param>
/// <param name="e">点击事件</param>
public void KeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Enter)
{
return;
}
if (!(sender is UIElement element))
{
return;
}
DependencyObject scope = FocusManager.GetFocusScope(element);
FocusManager.SetFocusedElement(scope, element);
Keyboard.ClearFocus();
}
}
}

View File

@@ -14,6 +14,7 @@
AllowDrop="True"
Drop="{s:Action DropFile}"
MouseDown="{s:Action MouseDown}"
KeyDown="{s:Action KeyDown}"
mc:Ignorable="d">
<Grid Margin="20" Background="White">
<Grid.ColumnDefinitions>