<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.gnustep.org/index.php?action=history&amp;feed=atom&amp;title=NSTextField</id>
	<title>NSTextField - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.gnustep.org/index.php?action=history&amp;feed=atom&amp;title=NSTextField"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.gnustep.org/index.php?title=NSTextField&amp;action=history"/>
	<updated>2026-05-05T14:24:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://mediawiki.gnustep.org/index.php?title=NSTextField&amp;diff=3016&amp;oldid=prev</id>
		<title>Cbv: Added categories</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.gnustep.org/index.php?title=NSTextField&amp;diff=3016&amp;oldid=prev"/>
		<updated>2006-04-21T15:47:12Z</updated>

		<summary type="html">&lt;p&gt;Added categories&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:47, 21 April 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l46&quot; &gt;Line 46:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 46:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;            else&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;            else&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                 return NO; // not allowing&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;                 return NO; // not allowing&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:AppKit]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Snippets]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Cbv</name></author>
	</entry>
	<entry>
		<id>https://mediawiki.gnustep.org/index.php?title=NSTextField&amp;diff=2010&amp;oldid=prev</id>
		<title>Cbv: Moved from Snippets</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.gnustep.org/index.php?title=NSTextField&amp;diff=2010&amp;oldid=prev"/>
		<updated>2005-09-05T13:42:50Z</updated>

		<summary type="html">&lt;p&gt;Moved from Snippets&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;NSTextField displays text a user can select or edit and sends its action message to its target when the user presses the Return key while editing.&lt;br /&gt;
&lt;br /&gt;
== Code chunks ==&lt;br /&gt;
&lt;br /&gt;
=== Testing ''chars'' entered by users in ''NSTextField'' ===&lt;br /&gt;
When the contents of a NSTextField are changed by the user, it is possible to check whether or not to accept the changes.&lt;br /&gt;
&lt;br /&gt;
1. Subclass NSTextField&lt;br /&gt;
&lt;br /&gt;
2. In your subclass implement the&lt;br /&gt;
         - (BOOL) textView: (NSTextView*) textView&lt;br /&gt;
         shouldChangeTextInRange: (NSRange) range&lt;br /&gt;
         replacementString: (NSString*) replacementString&lt;br /&gt;
method.&lt;br /&gt;
&lt;br /&gt;
3. Within this method you can access to the ''replacementString'' as an NSString, or as ''char'' with the following line:&lt;br /&gt;
         char c = *([replacementString cString] + 0);  &lt;br /&gt;
&lt;br /&gt;
4. You should return YES or NO depending on whether you accept the replacement string.&lt;br /&gt;
&lt;br /&gt;
=== Limiting text input length in ''NSTextField'' ===&lt;br /&gt;
(based on Alexander Malmberg's snippet)&lt;br /&gt;
&lt;br /&gt;
1. Subclass NSTextField&lt;br /&gt;
&lt;br /&gt;
2. In your subclass implement the&lt;br /&gt;
         - (BOOL) textView: (NSTextView*) textView&lt;br /&gt;
         shouldChangeTextInRange: (NSRange) range&lt;br /&gt;
         replacementString: (NSString*) replacementString&lt;br /&gt;
method.&lt;br /&gt;
&lt;br /&gt;
3. Also create an instance variable setting method:&lt;br /&gt;
          - (void) setMaxLength: (int) ml&lt;br /&gt;
          {&lt;br /&gt;
             maxLength = ml;&lt;br /&gt;
          } &lt;br /&gt;
&lt;br /&gt;
4. Then fill your implementation of textView:shouldChangeTextInRange:replacementString: with the following code:&lt;br /&gt;
          int newLength;&lt;br /&gt;
          /* The exact change isn't known. Disallow the change to be safe. */&lt;br /&gt;
           if (range.location == NSNotFound)&lt;br /&gt;
                return NO;&lt;br /&gt;
           newLength=[[textView textStorage] length]+[replacementString length]-range.length;&lt;br /&gt;
           if (newLength&amp;gt;maxLength)&lt;br /&gt;
                return YES; //allowing&lt;br /&gt;
           else&lt;br /&gt;
                return NO; // not allowing&lt;/div&gt;</summary>
		<author><name>Cbv</name></author>
	</entry>
</feed>