Post

Replies

Boosts

Views

Activity

Xcode15 beta 5 - I can't have multiple TextEditor in the same view (Preview only)
If I have the code below and do the following with preview on: Choose one of the TextEditors and start typing: works Go to another one. Start typing, the text shows only in the first one you chose. Try to delete the text while on the second (or third, or fourth) and you can't. Try to delete the text in the first one. It works. >.< If you check the preview console, you will see that the first variable is used forever. Is anyone having the same problem? So annoying having to run everything every single time. I'm running the Xcode on Sonoma 14.0. import SwiftUI struct TextStruct { var text1: String = "text1" var text2: String = "text2" } struct TextSummaryEditorView: View { @State private var textForSummary: String = "textForSummary" @State private var boomshakalaka: String = "boomshakalaka" @State private var textstruct: TextStruct = TextStruct(text1: "boo1", text2: "boo2") var body: some View { VStack { VStack { Text(textForSummary) TextEditor(text: $textForSummary) .textFieldStyle(PlainTextFieldStyle()) .font(.system(size: Config.defaultFontSize)) .padding() .background(Color("background").opacity(0.9)) .lineSpacing(10) .zIndex(1) .multilineTextAlignment(.leading) Text(boomshakalaka) TextEditor(text: $boomshakalaka) .textFieldStyle(PlainTextFieldStyle()) .font(.system(size: Config.defaultFontSize)) .padding() .background(Color("background").opacity(0.9)) .zIndex(0.9) Text(textstruct.text1) TextEditor(text: $textstruct.text1) .textFieldStyle(PlainTextFieldStyle()) .font(.system(size: Config.defaultFontSize)) .padding() .background(Color("background").opacity(0.9)) .lineSpacing(10) .zIndex(1) .multilineTextAlignment(.leading) Text(textstruct.text2) TextEditor(text: $textstruct.text2) .textFieldStyle(PlainTextFieldStyle()) .font(.system(size: Config.defaultFontSize)) .padding() .background(Color("background").opacity(0.9)) .zIndex(0.9) } .cornerRadius(Config.radioL) .onChange(of: boomshakalaka) { print(boomshakalaka) } Text("Button") } } } struct TextSummaryEditorView_Previews: PreviewProvider { static var previews: some View { VStack { TextSummaryEditorView() } .padding() .background(Color("background").opacity(0.4)) } }```
1
0
465
Aug ’23