How to select Text in SwiftUI on macOS

I have (inside a VStack) an HStack, which contains a few Texts.
Displays nicely.
But: I cannot select this line of text (and by implication: cannot copy the line).

Before SwiftUI I would have used an NSTextField with isSelectable = true.

How can this be done in SwiftUI ?



Currently, SwiftUI doesn't seem to have an option to select text from the Text View and you may have to resort to the old ways.

One way to allow copying strings from the Text View using SwiftUI is as below:

.contextMenu {
Button(action: {
UIPasteboard.general.string = stringDisplayed
}) {

1 Like
Terms of Service

Privacy Policy

Cookie Policy