From b7a715ec86a8affe1b141ebd7410cf0984ea1c7e Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Wed, 10 Jan 2024 06:58:56 +0100 Subject: [PATCH] macos: allow submitting clipboard confirmation with return Before this change I couldn't submit the dialog with return. Or cmd+return. From what I understand the problem was that the `TextEditor` always steals the default focus. I tried a bunch of workarounds I found to set the default focus on the button, but none of them worked. Then I thought: do we even need a full-on Text*Editor*? So I switched `TextEditor` to `Text` with a `ScrollView`: things look the same, text is selectable and scrollable, but I can hit return to submit the dialog. --- .../ClipboardConfirmationView.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/macos/Sources/Features/ClipboardConfirmation/ClipboardConfirmationView.swift b/macos/Sources/Features/ClipboardConfirmation/ClipboardConfirmationView.swift index 239b493c2..8a4f24678 100644 --- a/macos/Sources/Features/ClipboardConfirmation/ClipboardConfirmationView.swift +++ b/macos/Sources/Features/ClipboardConfirmation/ClipboardConfirmationView.swift @@ -48,10 +48,12 @@ struct ClipboardConfirmationView: View { .padding() } - TextEditor(text: .constant(contents)) - .textSelection(.enabled) - .font(.system(.body, design: .monospaced)) - .padding(.all, 4) + ScrollView { + Text(contents) + .textSelection(.enabled) + .font(.system(.body, design: .monospaced)) + .padding(.all, 4) + } HStack { Spacer()