Post

Replies

Boosts

Views

Activity

SwiftUI Undo/Redo Buttons for TextEditor/Keyboard
I'm using SwiftUI's simple TextEditor setup: struct TextEditorView: View {   @State var fullText: String = ""   var body: some View {     TextEditor(text: $fullText) .overlay( HStack{        Button(action:{undoType()}) {Image(systemName:"arrow.uturn.backward")}         Button(action:{redoType()}) {Image(systemName:"arrow.uturn.forward")}    ,alignment:.bottomTrailing)   } func undoType(){     //TODO: Undo the last typed edit     } func redoType(){     //TODO: Redo the last typed edit     } } Question: I'm asking how to implement simple Undo and Redo buttons in this TextEditorView for the iPhone specifically. Note: Swipe gestures for undo/redo function work perfectly. Three-finger swipe will undo/redo in this View. Undo/redo buttons appear on the iPad keyboard and work perfectly. (Command + Z) Keyboard command works when using an external keyboard. Any thoughts?
2
0
3.2k
Jun ’21