From c27759189d1243c01f3c16c74cf0c6de59a70be5 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Fri, 1 May 2026 17:43:29 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=BF=AB=E6=8D=B7=E9=94=AE=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Windows/HotkeyItem.xaml.cs | 19 +++++++++++++++++++ .../SettingsViews/Pages/HotkeyPage.xaml.cs | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/Ink Canvas/Windows/HotkeyItem.xaml.cs b/Ink Canvas/Windows/HotkeyItem.xaml.cs index 2dea883c..63cda413 100644 --- a/Ink Canvas/Windows/HotkeyItem.xaml.cs +++ b/Ink Canvas/Windows/HotkeyItem.xaml.cs @@ -77,12 +77,21 @@ namespace Ink_Canvas.Windows } } + private static HotkeyItem _activeCaptureItem; + private void StartHotkeyCapture() { + if (_activeCaptureItem != null && _activeCaptureItem != this) + { + _activeCaptureItem.StopHotkeyCapture(); + } + _activeCaptureItem = this; + CurrentHotkeyTextBlock.Text = "请按键..."; Focus(); KeyDown += HotkeyItem_KeyDown; KeyUp += HotkeyItem_KeyUp; + LostFocus += HotkeyItem_LostFocus; } private void StopHotkeyCapture() @@ -90,6 +99,16 @@ namespace Ink_Canvas.Windows UpdateHotkeyDisplay(); KeyDown -= HotkeyItem_KeyDown; KeyUp -= HotkeyItem_KeyUp; + LostFocus -= HotkeyItem_LostFocus; + if (_activeCaptureItem == this) + { + _activeCaptureItem = null; + } + } + + private void HotkeyItem_LostFocus(object sender, RoutedEventArgs e) + { + StopHotkeyCapture(); } private void HotkeyItem_KeyDown(object sender, KeyEventArgs e) diff --git a/Ink Canvas/Windows/SettingsViews/Pages/HotkeyPage.xaml.cs b/Ink Canvas/Windows/SettingsViews/Pages/HotkeyPage.xaml.cs index b620c7c6..b6baa9d7 100644 --- a/Ink Canvas/Windows/SettingsViews/Pages/HotkeyPage.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/Pages/HotkeyPage.xaml.cs @@ -90,6 +90,11 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages { try { + foreach (var hotkeyItem in _hotkeyItems.Values) + { + hotkeyItem.SetCurrentHotkey(Key.None, ModifierKeys.None); + } + if (_hotkeyManager != null) { var configHotkeys = _hotkeyManager.GetHotkeysFromConfigFile();