add:快捷键面板

This commit is contained in:
2026-05-01 17:43:29 +08:00
parent a33a399989
commit c27759189d
2 changed files with 24 additions and 0 deletions
+19
View File
@@ -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)
@@ -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();