Post

Replies

Boosts

Views

Activity

Reply to ReferenceFileDocument DOES NOT saving!
Recently, I've received feedback via the bug report and been suggested to register an undo. Turnout, the update of ReferenceFileDocument can be triggered, just like UIDocument, by registering an undo action. The difference is that the DocumentGroup explicitly setup the UndoManager via the Environment. For example, @main struct RefDocApp: App { 		var body: some Scene { 				DocumentGroup(newDocument: { 						RefDocDocument() 				}) { file in 						ContentView(document: file.document) 				} 		} } struct ContentView: View { 		@Environment(\.undoManager) var undoManager 		 		@ObservedObject var document: RefDocDocument 		var body: some View { 				TextEditor(text: Binding(get: { 						document.text 				}, set: { 						document.text = $0 						undoManager?.registerUndo(withTarget: document, handler: { 								print($0, "undo") 						}) 				})) 		} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’20