Questions tagged [swiftui-texteditor]
32 questions
8
votes
2 answers
Get `AttributeGraph: cycle detected` error when changing disabled state of text field
When I update the isDisabled state variable in my view, it updates the .disabled modifier of my text field as expected, but it then causes about 40 instances of the following error to appear in the console (with varying attribute numbers at the…

wristbands
- 1,021
- 11
- 22
7
votes
1 answer
Scrolling to TextEditor cursor position in SwiftUI
Is it possible to scroll to the TextEditor's current cursor position?
I have a List with a TextEditor as the last row. I'm scrolling to the last row of the List to make sure that the TextEditor is above the keyboard.
The problem is that since I have…

unknown
- 788
- 9
- 24
6
votes
0 answers
How can I align the content of a SwiftUI TextEditor to the origin of the view?
In SwiftUI I'm trying to get my TextEditor content into leading alignment with the Text above it. I have a pattern to do this in UIKit but can't seem to find the correct modifiers in SwiftUI.
In the attached screenshot, I'd like the text origin to…

Dustin Pfannenstiel
- 552
- 3
- 15
6
votes
3 answers
Detecting keyboard "submit button" press for TextEditor SwiftUI
On SwiftUI's TextField you can set an action for the return/submit button of the keyboard using the .onSubmit() modifier. How do you achieve the same with TextEditor? (.onSubmit() doesn't seem to work.)

unknown
- 788
- 9
- 24
5
votes
1 answer
How to add numbered/bulleted list in SwiftUI?
How to do this in SwiftUI in TextEditor? I thought of reading return from keyboard. TextField has onEditingChanged and onCommit, but TextEditor doesn't.
In Notes app it detects automatically the numbered list, and has button for adding bulleted…

MikeMaus
- 385
- 3
- 22
4
votes
1 answer
Move TextEditor (in List) up when the keyboard appeared in SwiftUI
I have a SwiftUI List with a TextEditor as the last row. In SwiftUI text fields automatically move up above the keyboard. But unfortunately when the TextEditor is in a List it doesn't seem to work.
There has been a lot of good solutions for this…

unknown
- 788
- 9
- 24
3
votes
1 answer
Adding margins to TextEditor
I'm adding margins to the TextEditor. While keeping these margins as clickable area.
I was able to add textContainerInset and problem is that added Inset is not clickable.
Current code:
extension NSTextView {
open override var frame: CGRect {
…

yaosamo
- 126
- 1
- 10
2
votes
0 answers
How to past an image in TextEditor SwiftUI like oneNote/notion?
I want to paste an image in line with text like apps one note or notion do. I read somewhere that it's impossible with TextEditor and I had to use UITextView instead, so I did that but I do not know how to trigger the event PASTE to paste the…

Nat Serrano
- 472
- 1
- 4
- 17
2
votes
0 answers
incorrect mouse cursor on some view in case view below is TextEditor
struct Test: View {
@State var text: String = ""
var body: some View {
ZStack {
TextEditor(text: $text)
Rectangle()
.fill(Color.green)
.padding()
…

Andrew_STOP_RU_WAR_IN_UA
- 9,318
- 5
- 65
- 101
2
votes
3 answers
AutoComplete search in swiftui not working
I have a TextField as search box.I want to make it autosearch i.e whenever i will enter a letter in the TextField, i should get the result without press a enter.Here is my code:
TextField("Search", text: $searchText,
onEditingChanged: {
…

Santanu
- 337
- 1
- 3
- 13
2
votes
1 answer
SwiftUI TextEditor Initial Content Size Is Wrong
iOS 14.4 + Xcode 12.4
I want to make a simple checklist in SwiftUI on iOS where the text for each item is a TextEditor.
First, I create the basic app structure and populate it with some demo content:
import SwiftUI
@main
struct TestApp: App {
…

Clifton Labrum
- 13,053
- 9
- 65
- 128
1
vote
1 answer
All TextEditor are resized when any TextEditor has more than one line
I have a problem. I have a view with several TextEditors. Typing in any of them changes the height of all of them.
Do you have any idea what happens and how to fix it?
Example Code:
import SwiftUI
struct TestingView: View {
@State…

Ariel Antonio Fundora
- 1,330
- 15
- 20
1
vote
1 answer
SwiftUI Text Editor Crash with Apple Pencil Long Press
Using Apple Pencil with SwiftUI text editor, when the user presses and holds in the middle of text already in the editor box a crash occurs. This is very reproducible even on this minimal example.
import SwiftUI
struct ContentView: View {
…

Mike R
- 568
- 4
- 11
1
vote
1 answer
How would you dismiss keyboard inside text editor?
I haven't found any documentation on it. I know you can dismiss keyboard using .keyboardDismissMode on TabliewView and other UIViews but how would you do that with TextEditor() in SwiftUI? I have a swipe gesture feature right now but that doesn't…

alex
- 118
- 1
- 6
1
vote
1 answer
Change characters typed on TextEditor in SwiftUI
I'm trying to capture the text typed in a TextEditor, store it in a variable and update what is displayed on the TextEditor itself. I'm using the .onChange() to trigger and capture what is being typed, store it in a variable, and change the current…

Boga
- 371
- 3
- 14