fix: give native Quit its Command shortcut during text editing

This commit is contained in:
2026-10-12 15:18:42 +02:00
parent b2dc5fa373
commit 30cf85e880
5 changed files with 25 additions and 9 deletions
+7 -1
View File
@@ -94,6 +94,11 @@ extension PlayerModel {
}
func performMenuAction(_ action: PlayerAction) {
// Native Command-Quit remains available while a text field owns focus.
if action == .quit, NSApp.currentEvent?.modifierFlags.contains(.command) == true {
perform(action)
return
}
if let event = NSApp.currentEvent, event.type == .keyDown {
if event.isARepeat && !action.allowsRepeat { return }
guard let chord = KeyChord.from(event),
@@ -162,10 +167,11 @@ struct PlayerCommands: Commands {
let bufferInfo = model.bufferInfoAction
let snapping = model.snappingAction
let automaticQuality = model.automaticQualityAction
let quitKeys = model.keyBindings.shortcuts(for: .quit)
CommandGroup(replacing: .appTermination) {
Button("Quit terebi") { model.performMenuAction(.quit) }
.keyboardShortcut(model.keyBindings.shortcuts(for: .quit).first?.keyboardShortcut)
.keyboardShortcut((quitKeys.first { $0.modifiers.contains(.command) } ?? quitKeys.first)?.keyboardShortcut)
.disabled(!model.canPerform(.quit))
}
CommandGroup(replacing: .newItem) {
+1 -1
View File
@@ -1582,7 +1582,7 @@ private struct PlayerContent: View {
HStack(spacing: 8) {
TextField("YouTube video URL", text: $youTubeURL,
prompt: Text("YouTube video URL")
.foregroundStyle(Color(SunsetPalette.secondaryText)))
.foregroundStyle(Color(SunsetPalette.secondaryText).opacity(0.6)))
.textFieldStyle(.plain)
.focused($youTubeInputFocused)
.accessibilityLabel("YouTube video URL")