Skip to content

Commit 845fd02

Browse files
authored
fix(formmain): 修复弹窗时按下回车导致崩溃的问题 (#2805)
(由 GPT-5.4-mini 生成)
1 parent 1fe74f8 commit 845fd02

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Plain Craft Launcher 2/FormMain.xaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,17 @@ private void FormMain_KeyDown(object sender, KeyEventArgs e)
748748
{
749749
if (e.Key == Key.Enter)
750750
{
751-
((MyMsgInput)PanMsg.Children[0]).Btn1_Click(sender, null);
751+
var msg = PanMsg.Children[0];
752+
Action? enterAction = msg switch
753+
{
754+
MyMsgInput input => () => input.Btn1_Click(sender, null),
755+
MyMsgSelect select => () => select.Btn1_Click(sender, null),
756+
MyMsgText text => () => text.Btn1_Click(sender, null),
757+
MyMsgMarkdown markdown => () => markdown.Btn1_Click(sender, null),
758+
MyMsgLogin login => () => login.Btn1_Click(sender, null),
759+
_ => null
760+
};
761+
enterAction?.Invoke();
752762
return;
753763
}
754764

0 commit comments

Comments
 (0)