47 questions
1
vote
0
answers
79
views
How to dynamically size TextEditor like TextField in SwiftUI
In SwiftUI, you can dynamically size a TextField like this which expands vertically as the user types.
TextField("Enter text", text: $text, axis: .vertical)
I would like to do the same thing ...
-3
votes
0
answers
49
views
MacOS: Using TextEditor with AttributedString uses wrong selection highlight colour in dark mode?
I am using the new AttributedString in Swift 26 with a TextEditor in dark mode to track selections for a qualitative data analysis tool.
ISSUE:
In dark mode, the highlight colour inherited from system ...
0
votes
1
answer
54
views
AttributedString: Mixed attributes get overwritten
I am trying to build a very simple text editor with SwiftUI for iOS and macOS 26.
Like with any editor I would expect to only change the bold attribute when pressing the bold button. It seems like ...
1
vote
1
answer
307
views
SwiftUI TextEditor inside ScrollView is hidden by keyboard when entering long text
I'm building a SwiftUI demo where I have a list of editable text fields using TextEditor inside a ScrollView. Each field is dynamically created and uses a custom MultilineTextFieldView. The UI works ...
1
vote
1
answer
128
views
SwiftUI TextEditor UI glitch on macOS if line breaks
In SwiftUI macOS TextEditor I noticed a weird behaviour, the whole text is sometimes flickering if a word breaks to a new line. Unfortunately I could not find any fix as it appears in this simple ...
0
votes
1
answer
153
views
SwiftUI TextEditor Not Respecting .ignored KeyPress.Result
I have a TextEditor in SwiftUI and I'm doing some custom things when the user taps return or backspace.
TextEditor(text: $item.text)
.focused($focusedItem, equals: item.id)
.onKeyPress(...
0
votes
2
answers
71
views
adding phantom padding when setting fixed height
I have a very simple TextEditor in a SwiftUI Form to allow users to send feedback about the app.
I want to set a minHeight and maxHeight for the text field so that it's clear the user can enter ...
0
votes
1
answer
332
views
How to prevent SwiftUI view to redraw every time on Published property update?
I have a LandingView that has a viewModel which is an ObservableObject. LandingView loads some CardViews dynamically and passes a model object (Binding property).
CardView further nests four different ...
0
votes
0
answers
82
views
How to make TextEdit untapable but scrollable in SwiftUI
I have a TextEditor, which is covered by another View in ZStack:
ZStack {
TextEditor()
MyView()
}
The idea that I have 2 modes: edit and view. In edit view I remove MyView from ZStack. In view ...
0
votes
2
answers
1k
views
How Do I Correctly Style SwiftUI TextEditor
I'm working on an app with forms for the user, and I wanted to style my TextField and TextEditor instances the same. The former seem easy enough but I'm not convinced I'm constructing the latter ...
2
votes
2
answers
697
views
SwiftUI TextEditor internal scroll padding without text cropping
Im building note view with footer over whole UI
var body: some View {
ZStack(alignment: .bottom) {
VStack(alignment: .leading) {
Text("\(note.date.formatted())")
...
0
votes
1
answer
264
views
How can I add a Button() inside of TextEditor() in SwiftUI?
I'd like try be able to add buttons inside of TextEditor() or a custom text editor.
Is this possible with SwiftUI?
2
votes
1
answer
435
views
Default focus on TextEditor does not work
I want to make a textEditor have default focus when a view appears in SwiftUI. My approach works for a textField but not a textEditor. I'm not sure why this is.
struct ContentView: View {
enum ...
1
vote
1
answer
368
views
How to save edited content in SwiftUI?
My goal is to save the contents only if the user taps "Save", but to discard the edits when they click "Cancel".
That's why I created two variables that receive the initial values ...
-1
votes
1
answer
365
views
Mac OS SwiftUI inline text editing completions
Xcode on OS X has really nice inline automatic completions / suggestions while editing text with embedded documentation and such. How would I even start to achieve something like this using SwiftUI's ...
0
votes
1
answer
2k
views
How to Automatically Scroll Text Upwards in SwiftUI TextEditor as Keyboard Appears?
I am working on an iOS application using SwiftUI. In my app, I have a TextEditor where the user can enter text. As the user writes and the text becomes longer, the TextEditor's content moves downwards,...
1
vote
1
answer
62
views
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
...
0
votes
1
answer
1k
views
SwiftUI TextEditor is not editable even though it is
With the below code, if we run on simulator the editing seems to work.
However in the swift UI preview it does not seem to be editing. It shows "Scan Text" but not allow me to enter text ...
0
votes
1
answer
660
views
Placeholder is not on the same line with text SwiftUI
I want to have a placeholder when there is no text in the texteditor, is working well, but the placeholder is not on the same line with the cursor of the TextEditor. I tried to replace the TextEditor ...
2
votes
1
answer
373
views
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.
...
0
votes
2
answers
944
views
Swiftui TextEditor seems not to respond to state changes
I am having trouble getting the SwiftUI TextEditor to work when it is in a Child View.
This is a small example that demonstrates the issue for me:
import SwiftUI
struct ContentView: View {
@State ...
6
votes
1
answer
496
views
SwiftUI: How to make TextEditor field tabbable on MacOS
I have a two text fields on my View. I want to be able to tab between them. It is currently writing the tab into the text content.
struct MyView: View
{
@State var field1: String
@State var ...
4
votes
0
answers
918
views
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 ...
0
votes
1
answer
275
views
How can i make this TextEditor text appear on fullscreen, unlike inside this scrolling frame
I am trying to display this text inside TextEditor in full screen but it is showingup inside this scrolling frame.
I've tried this method .fixedSize(horizontal: false, vertical: true) on TextEditor ...
2
votes
0
answers
116
views
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()
....
1
vote
1
answer
283
views
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 ...
0
votes
1
answer
498
views
how to text.append() a Hyperlink to TextEditor Swiftui
I have a TextEditor that i want to add a clickable Hyperlink using the TextEditor text.append()
TextEditor(text: $textE)
.textFieldStyle(.roundedBorder)
textE.append(contentsOf: &...
1
vote
0
answers
69
views
updating text inside TextEditor via code - Xcode swift
I'm trying to update the text inside TextEditor via code with no luck and i can't find any examples - Xcode swift
basically I would like to create a scrollable multiline log that can be
highlighted ...
0
votes
1
answer
2k
views
SwiftUI Text Editor how can I keep track of the number of lines in the editor
I have a TextEditor using SwiftUI 3.0 and every time a new line is created I want to increase the editor height by about 16 points . The issue that I have is that my code is not recognizing the new ...
1
vote
1
answer
3k
views
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,...
1
vote
0
answers
419
views
NSTextView not being found in project scope SwiftUI
I'm trying to add a TextEditor to my project with a different background color. I'd like to just use the simple extension that's found in this post: Transparent Background for TextEditor in SwiftUI
...
0
votes
0
answers
515
views
I there anyway to have multiple colors in a SwiftUI TextEditor text?
I am using a SwiftUI TextEditor and would like to change the color of characters from when user has typed in a certain number of characters. Is there any way to achieve this?
So there will be two ...
7
votes
0
answers
790
views
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 ...
1
vote
0
answers
382
views
SwiftUI document-based apps on macOS: How to prevent TextEditor from setting document edited
Problem
I am working on a simple SwiftUI document-based app on macOS (12.0.1) with Xcode 13.2.1.
In my app, I need two TextEditors in the document view. One displays the content of the document, and ...
4
votes
1
answer
2k
views
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 ...
7
votes
3
answers
6k
views
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....
13
votes
2
answers
6k
views
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 ...
3
votes
1
answer
2k
views
TextField's .focused modifier not working when "out of view" SwiftUI
I'm working with a SwiftUI List with a TextEditor at the bottom of the List. The TextEditor becomes active or "Focused" when a button is pressed.
To achieve this, I have added a .focused ...
4
votes
1
answer
2k
views
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.
...
9
votes
2
answers
4k
views
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 ...
1
vote
1
answer
704
views
SwiftUI TextEditor View content is hidden behind Navigation Bar
I'm working on a SwiftUI View with a NavigationBar. The view is very simple, it's a full-page TextEditor:
struct NotesEditingScreen: View {
@State var text: String
var body: some ...
0
votes
0
answers
191
views
SwiftUI TextEditor: console message: [Assert] View <(null):0x0> does not conform to UITextInput protocol
I am using this EditNotesView, which when I coded it 6 months ago worked fine, but now when I tap in the TextEditor the keyboard comes up, but there isn't a cursor in the TextEditor. If I tap again ...
2
votes
1
answer
789
views
SwiftUI Text Editor with a floating label
I am trying to style a Text Editor in SwiftUI to look like a Material Design element. Currently, I'm struggling with the floating label.
I cannot figure out how to capture the editing state of Text ...
4
votes
3
answers
6k
views
How to make TextEditor look like TextField - SwiftUI
I'm looking for a way to make a swiftUI TextEditor look like a TextField. I need a multiline input but I really like the appearance of rounded TextFields.
This is the closest I was able to get:
Using ...
2
votes
3
answers
797
views
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&...
7
votes
2
answers
16k
views
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 ...
2
votes
1
answer
3k
views
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:
...