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.
This commit is contained in:
Thorsten Ball
2024-01-10 06:58:56 +01:00
parent fc30fdfb2b
commit b7a715ec86

View File

@ -48,10 +48,12 @@ struct ClipboardConfirmationView: View {
.padding()
}
TextEditor(text: .constant(contents))
ScrollView {
Text(contents)
.textSelection(.enabled)
.font(.system(.body, design: .monospaced))
.padding(.all, 4)
}
HStack {
Spacer()