When creating a plain window in SwiftUI on macOS 15.0 beta, the TextEditor within the window does not accept keyboard input. I suspect it's because plain windows cannot become key windows.
Here is a minimal example:
import SwiftUI
struct ContentView: View {
@State var text: String = "Hello World"
var body: some View {
VStack {
TextEditor(text: $text)
}
}
}
@main
struct BigTextApp: App {
var body: some Scene {
Window("Text Window", id: "TextWindow") {
ContentView()
}
.windowStyle(.plain)
}
}
Attempting to type gives the following warning in Xcode: Warning: -[NSWindow makeKeyWindow] called on SwiftUI.AppKitWindow which returned NO from -[NSWindow canBecomeKeyWindow].
Is there a way to make the window capable of becoming a key window without dropping down to UIKit? Or is there another way to allow the TextEditor to accept keyboard input?
I have tried focusing the TextEditor, but that didn't work.