From 7dc0d8ce26d7f7915af5ffb462510264811bb685 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Fri, 24 Apr 2026 22:27:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SettingsWindow=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E6=94=AF=E6=8C=81=20Cmd+A/C/V/X=20=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/UI/SettingsWindow.swift | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Sources/UI/SettingsWindow.swift b/Sources/UI/SettingsWindow.swift index efcfc67..0504cc9 100644 --- a/Sources/UI/SettingsWindow.swift +++ b/Sources/UI/SettingsWindow.swift @@ -40,6 +40,35 @@ final class SettingsWindow: NSWindow { center() } + // MARK: - 快捷键支持(LSUIElement 无 Edit 菜单,需手动转发) + + override func performKeyEquivalent(with event: NSEvent) -> Bool { + // 仅拦截 Cmd 组合键 + guard event.modifierFlags.contains(.command) else { + return super.performKeyEquivalent(with: event) + } + + let selector: Selector? + switch event.charactersIgnoringModifiers?.lowercased() { + case "a": selector = #selector(NSText.selectAll(_:)) + case "c": selector = Selector(("copy:")) + case "v": selector = Selector(("paste:")) + case "x": selector = Selector(("cut:")) + default: selector = nil + } + + guard let sel = selector else { + return super.performKeyEquivalent(with: event) + } + + // 发送到第一响应者链 + if NSApp.sendAction(sel, to: nil, from: self) { + return true + } + + return super.performKeyEquivalent(with: event) + } + private func buildUI() { guard let content = contentView else { return }