<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: SwiftUI TextEditor character limit	</title>
	<atom:link href="https://softwareanders.com/swiftui-texteditor-character-limit/feed/" rel="self" type="application/rss+xml" />
	<link>https://softwareanders.com/swiftui-texteditor-character-limit/</link>
	<description>Blog about software development - with focus on Swift and SwiftUI</description>
	<lastBuildDate>Fri, 01 Dec 2023 11:41:15 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>
		By: Gareth		</title>
		<link>https://softwareanders.com/swiftui-texteditor-character-limit/#comment-10</link>

		<dc:creator><![CDATA[Gareth]]></dc:creator>
		<pubDate>Fri, 01 Dec 2023 11:41:15 +0000</pubDate>
		<guid isPermaLink="false">https://softwareanders.com/?p=369#comment-10</guid>

					<description><![CDATA[I&#039;ve done something similar to this to limit text, and it works well except for if the cursor isn&#039;t at the end of the text...
If the text count is at the limit, and then you move the cursor to the front and type a character, then the character is entered, and then the last character is dropped and the cursor ends up at the end of the text.
So a text limit of 5 and the string &quot;abcde&quot;, with the cursor at the front, if you enter &quot;1&quot;, the string will become &quot;1abcd&quot; and place the cursor at the end.

I have found a reasonable way to prevent this, by caching the last valid text and setting the text back to that in the event that you exceed the count, which works for keeping the text as it was, but still has the cursor jumping problem. Not sure there is currently a way of dealing with the cursor position completely in SwiftUI at the moment]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done something similar to this to limit text, and it works well except for if the cursor isn&#8217;t at the end of the text&#8230;<br />
If the text count is at the limit, and then you move the cursor to the front and type a character, then the character is entered, and then the last character is dropped and the cursor ends up at the end of the text.<br />
So a text limit of 5 and the string &#8220;abcde&#8221;, with the cursor at the front, if you enter &#8220;1&#8221;, the string will become &#8220;1abcd&#8221; and place the cursor at the end.</p>
<p>I have found a reasonable way to prevent this, by caching the last valid text and setting the text back to that in the event that you exceed the count, which works for keeping the text as it was, but still has the cursor jumping problem. Not sure there is currently a way of dealing with the cursor position completely in SwiftUI at the moment</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: softwareanders.com @ 2026-07-25 02:55:09 by W3 Total Cache
-->