You can use overlay modifier like this:
struct ContentView: View {
@State private var string: String = "Hello, World!"
@State private var disableStringSelection: Bool = Bool()
var body: some View {
VStack(spacing: 5.0) {
Color.white
.overlay(disableStringSelection ? Text(string).font(Font.body).padding(.leading, 5.0) : nil, alignment: .topLeading)
.overlay(disableStringSelection ? nil : TextEditor(text: $string).font(Font.body))
.cornerRadius(10.0)
Button(disableStringSelection ? "Enable Selection" : "Disable Selection") { disableStringSelection.toggle() }
}
.padding(5.0)
}
}

Update:
The new update will support dark mode as well:
struct ContentView: View {
@State private var string: String = "Hello, World!"
@State private var disableStringSelection: Bool = Bool()
var body: some View {
VStack(spacing: 5.0) {
Color(NSColor.textBackgroundColor)
.overlay(disableStringSelection ? Text(string).font(Font.body).padding(.leading, 5.0) : nil, alignment: .topLeading)
.overlay(disableStringSelection ? nil : TextEditor(text: $string).font(Font.body))
.animation(nil)
.cornerRadius(10.0)
.foregroundColor(Color(NSColor.labelColor))
.frame(width: 400.0, height: 200.0, alignment: .center)
Button(disableStringSelection ? "Enable Selection" : "Disable Selection") { disableStringSelection.toggle() }
.foregroundColor(Color(NSColor.labelColor))
}
.padding(5.0)
}
}
extension NSTextView {
open override var frame: CGRect {
didSet { backgroundColor = NSColor.clear }
}
}
NSCursordon't seem to work at all. Since theTextEditoris disabled anyway, why not just useTextto display your content?Textview.