From 8596d39d89b7285a01a53b4332fae60aff5fc09e Mon Sep 17 00:00:00 2001
From: lhhxxxxx <91231470+lhhxxxxx@users.noreply.github.com>
Date: Tue, 23 Aug 2022 05:19:27 +0800
Subject: [PATCH] =?UTF-8?q?feat.=20=E8=BE=93=E5=85=A5=E7=A5=9E=E7=A7=98?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8E=E7=82=B9=E6=97=81=E8=BE=B9=E5=8D=B3?=
=?UTF-8?q?=E5=8F=AF=E5=8A=A0=E8=BD=BD=E7=9B=B8=E5=85=B3=E6=96=87=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/MeoAsstGui/ViewModels/CopilotViewModel.cs | 21 ++++++++++++++++++-
src/MeoAsstGui/Views/CopilotView.xaml | 1 +
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs
index 3fded122d3..d272e1bec3 100644
--- a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs
+++ b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs
@@ -20,11 +20,13 @@ using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using System.Windows.Forms;
+using System.Windows;
+using System.Windows.Input;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stylet;
using StyletIoC;
+using DataFormats = System.Windows.Forms.DataFormats;
using DragEventArgs = System.Windows.DragEventArgs;
using Screen = Stylet.Screen;
@@ -460,5 +462,22 @@ namespace MeoAsstGui
{
}
}
+
+ ///
+ /// 点击后移除界面中元素焦点
+ ///
+ /// 点击事件发送者
+ /// 点击事件
+ public void MouseDown(object sender, MouseButtonEventArgs e)
+ {
+ if (!(sender is UIElement element))
+ {
+ return;
+ }
+
+ DependencyObject scope = FocusManager.GetFocusScope(element);
+ FocusManager.SetFocusedElement(scope, element);
+ Keyboard.ClearFocus();
+ }
}
}
diff --git a/src/MeoAsstGui/Views/CopilotView.xaml b/src/MeoAsstGui/Views/CopilotView.xaml
index 4c24e35246..7842ea2d66 100644
--- a/src/MeoAsstGui/Views/CopilotView.xaml
+++ b/src/MeoAsstGui/Views/CopilotView.xaml
@@ -13,6 +13,7 @@
d:DesignWidth="800"
AllowDrop="True"
Drop="{s:Action DropFile}"
+ MouseDown="{s:Action MouseDown}"
mc:Ignorable="d">