<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TextField &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/textfield/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Mon, 04 Feb 2019 20:04:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Quick Tip: Hiding the Border in iOS Text Fields</title>
		<link>https://blog.xojo.com/2017/09/11/quick-tip-hiding-the-border-in-ios-text-fields/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 11 Sep 2017 17:15:07 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Declares]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[TextField]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3358</guid>

					<description><![CDATA[Learn a simple way to hide the border on an iOS Text Field. ]]></description>
										<content:encoded><![CDATA[<p>The other day Geoff was working an iOS project and asked me if there was a way to hide the border on an iOS Text Field. It turns out that this is pretty easy. Here&#8217;s how.</p>
<p><span id="more-3358"></span></p>
<p>If you go to the <a href="http://developer.xojo.com/iostextfield">iOSTextField</a> page in the Xojo Dev Center, you won&#8217;t find a property to hide or change the border. However, that page does have a link to the native iOS control that Xojo uses behind the scenes: <a href="https://developer.apple.com/documentation/uikit/uitextfield#//apple_ref/doc/uid/TP40006888">UITextField</a>. I clicked that link to get the Apple Dev Center docs for <a href="https://developer.apple.com/documentation/uikit/uitextfield#//apple_ref/doc/uid/TP40006888">UITextField</a>.</p>
<p>On that page I did a find for the word &#8220;border&#8221;. This found a section of the doc page with a link to the <a href="https://developer.apple.com/documentation/uikit/uitextfield/1619624-borderstyle">borderStyle property</a>. I clicked it to see its declaration, shown below:</p>
<p><strong>Objective-C:</strong></p>
<pre>@property(nonatomic) UITextBorderStyle borderStyle;</pre>
<p><strong>Swift:</strong></p>
<pre>var borderStyle: UITextBorderStyle { get set }</pre>
<p>These declarations both tell me that borderStyle is essentially a computed property (indicated by the &#8220;@property&#8221; in Objective-C or the &#8220;{get set}&#8221; in Swift). I next clicked on <a href="https://developer.apple.com/documentation/uikit/uitextborderstyle">UITextBorderStyle</a> to see what value you assign to it and it turns out it is just a series of Integer constants:</p>
<pre>none = 0
line =1
bezel = 2
roundedRect = 3</pre>
<p>(Xojo uses roundedRect by default for TextField borders.)</p>
<p>I now have enough information to write a simple <a href="http://developer.xojo.com/declare">Declare command</a> to use this property to change the border. But there is one trick to remember. Since this is a computed property you have to alter the property name to include &#8220;set&#8221; at the beginning and change the case accordingly. (My understanding is that this is because it is really a method behind the scenes.) So the name being called is actually &#8220;setBorderStyle&#8221;. Since this is referring to a UI control, the library is &#8220;UIKit.Framework&#8221; and the Declare needs to pass in the handle to the TextField (as a Ptr) and the border style (as an Integer).</p>
<p>The final Declare looks like this:</p>
<pre>Declare Sub setBorderStyle Lib "UIKit.Framework" Selector "setBorderStyle:" (obj As Ptr, value As Integer)</pre>
<p>You can put that Declare on the Open event of your TextField and the call it with this code:</p>
<pre>Const kBorderNone = 0
setBorderStyle(Me.Handle, kBorderNone)</pre>
<p>Here is how a TextField looks with and without a border:</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-3360" style="border: 3px solid #eeeeee; padding: 3px; margin: 3px;" src="https://blog.xojo.com/wp-content/uploads/2017/09/Simulator-Screen-Shot-Sep-7-2017-2.36.12-PM.png" alt="" width="320" height="568" /></p>
<p>Watch the video:</p>
<p><iframe title="Create a Custom iOS Text Field with Border Styles" width="500" height="281" src="https://www.youtube.com/embed/UG75CiJav7A?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>TextField: Getting the User Input</title>
		<link>https://blog.xojo.com/2017/02/06/textfield-getting-the-user-input/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Mon, 06 Feb 2017 20:52:48 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[TextField]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2258</guid>

					<description><![CDATA[Xojo is a modern, powerful programming language with an IDE that simplifies all kind of tasks related your project creation and deployment. One such helpful feature is the&#8230;]]></description>
										<content:encoded><![CDATA[<p><strong>Xojo</strong> is a modern, powerful programming language with an <strong>IDE</strong> that simplifies all kind of tasks related your project creation and deployment. One such helpful feature is the UI layout design; you can find it under the Library Panel, it&#8217;s a meaningful collection of graphic classes (Controls) ready to use in our apps. Probably one of the first and most used controls in apps design is the <a href="http://developer.xojo.com/textfield"><strong>TextField</strong></a>, TextField simplifies the way an app can get the input from the user. Let&#8217;s see its main properties and how this control behaves when used in Desktop, Web (<a href="http://developer.xojo.com/webtextfield">WebTextField</a>) and iOS (<a href="http://developer.xojo.com/iostextfield">iOSTextField</a>) apps!</p>
<p>You can watch <a href="https://www.youtube.com/watch?v=CWy7phIErg4">the video</a> (in Spanish, with English subtitles) as you read and work through this post.<span id="more-2258"></span></p>
<h2>It&#8217;s all about the content: Text</h2>
<p>The main property of the control is the <b>Text</b> property. Accessing this property we can get the text typed by the user of the app…or set the text that we want the control to show (using Text or String data types). This property is available for all the supported platforms without variations.</p>
<p>Obviously, we can set the text shown by the control by default using the <b>Initial State</b> section of the Inspector Panel. Here is where we can find the <b>CueText</b> property for Web and Desktop apps, or the <b>PlaceHolder</b> property for iOS apps. Anyway, the text put here will be shown as <em>ghost text</em> by the control when there is not text entered from the user, giving a hint to the user about the kind of input data our app expect to be entered in the control instance.</p>
<p>Optionally, the Desktop and Web implementations of this control also offer the <b>HelpTag</b> property. Here is we can enter the text to be show to the user as a little help about the control purpose. This text will be automatically shown when the user puts the mouse pointer over the control during a second or so.</p>
<h2>Give me the Password</h2>
<p>Sometimes it&#8217;s very convenient to use the boolean property <b>Password</b>. Once enabled, the TextField will hide the control content from prying eyes, using a series of dots instead of every one of the typed characters. This is, in fact, the way to go when we need that the user of the app enters a Password or any kind of sensible data that shouldn&#8217;t be exposed otherwise.</p>
<p>As it happens with the <b>Text</b> property, the <b>Password</b> property is available for the creation and deployment of Desktop Apps (macOS, Windows, Linux, <a href="https://www.xojo.com/raspberrypi/"><strong>Raspberry Pi</strong></a>), web and native iOS apps. The only difference is that, for web apps, the TextField control will offer the option to save the password for later retrieval, something that only is available for that web browsers that support this feature (as it is with Safari under macOS). For iOS apps, the password behaviour will be the one we can expect from a native iOS app, showing in a fast succession the tapped key and hiding it in the blink of a eye.</p>
<h2>TextField appearance</h2>
<p>When it&#8217;s about the properties related mainly to the appearance of the text shown by this control, we can set several properties under the Attributes Inspector Panel for Desktop apps, as for example the Type, text Size and Style, as its the case when using this control in iOS apps. In addition, we can use the main area of the Properties Inspector to change the text alignment, text color and also the background color (only for Desktop apps, not in the case of iOS apps).</p>
<p>When it&#8217;s about web apps, all the issues related with the text style are related with the assignment of a Web Style that we have had defined previously, and whose creation and assignment is pointed in the video accompanying this blog entry.</p>
<p>When using this control on Desktop apps we can also set other appearance attributes, for example, the use of a border (it is not possible to assign the border color and/or border thickness), the use of the focus ring that points out the control active to receive the user keyboard input, and the feature already exposed that allows us to define the control background color; something that is also possible when using the control with Web apps, via the associated property during a Web Style definition.</p>
<h2>How to limit the text length</h2>
<p>There are several ways to limit the length of the text that the user can type on a TextField, mainly by kind of data or number of characters. The simpler is obviously the second option, available when using the TextField on Desktop apps and Web apps, via the <b>LimitText</b> property.</p>
<h2>Applying format to the Text</h2>
<p>There are countless the kind of apps where we would want to apply a specific format to the text typed by the user, and in fact we can turn again to the TextField properties to find the way to do it! However, we will have more or less flexibility if we are dealing with a Desktop app, a Web app or an iOS app.</p>
<p><img decoding="async" class="wp-image-2262 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2017/02/TextFieldMascara-1024x688.png" width="800" height="538" /></p>
<h3>Desktop</h3>
<p>For example, when using a TextField with Desktop apps (macOS, Windows, Linux), we can use the <b>Mask</b> property to apply an specific format to the typed data. In these cases, the format will be applied once the control loses its focus. For example, the following format sequence applied in the <b>Mask</b> property:</p>
<pre>###,###.00\ \€</pre>
<p>will automatically format the number &#8220;123456&#8221; as:</p>
<pre>123.456,00 €</pre>
<p>Notice that even if we use the English notation (the comma as thousands separator and the dot as decimal separator), our app will apply the <a href="http://blog.xojo.com/2017/01/24/localizing-web-apps/">regional settings configured</a> on the computer that runs the app. I mean, it will format correctly the string using the appropriate regional settings on every case.</p>
<h3>Web</h3>
<p>In this case we could talk about a combination between text format and text restriction. For that, we can choose any of the options available under the popup menu <b>Type</b> under the Appearance section of the Inspector Panel:</p>
<ul>
<li><b>Normal</b>. The <b>WebTextField</b> will show any typed text.</li>
<li><b>Password</b>. It will behave as explained under the Password section, hiding the typed text.</li>
<li><b>E-mail Address</b>. The control will show an error ring if the typed text doesn&#8217;t seems to be a legal e-mail address. For that, it only seeks for the presence of the &#8216;at&#8217; symbol (&#8216;@&#8217;) and a dot character (&#8216;.&#8217;) in the entered text.</li>
<li><b>Number</b>. The control will show an error ring if the typed content is not exclusively numeric. This is something similar to the example we have seen with the <b>Mask</b> in a Desktop app, except that in this case the control adds a couple of graphical widgets that allows us to increase or decrease the TextField value when clicking on them.</li>
<li><b>Telephone Number</b>. At first, this option should accept only the input of a legal phone number, but in practice it will admit any kind of data.</li>
<li><b>URL</b>. As it happens with the previous item, it should admit and show just the kind of data for a legal URL, but in practice it will admit any text composition.</li>
</ul>
<p><img loading="lazy" decoding="async" class="size-full wp-image-2261 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2017/02/iOSTextField_Keyboard.png" alt="" width="325" height="254" /></p>
<h3>iOS</h3>
<p>In this case it is mainly about setting the kind of keyboard shown to the user once he taps on the TextField, where we can choose the most adequate for numeric values, URL, e-mail or general text, between some of all the available options.</p>
<p>So that&#8217;s the TextField control. You can watch <a href="https://www.youtube.com/watch?v=CWy7phIErg4" target="_blank">the video</a> (in Spanish, with English subtitles) that talks you though this example. And remember, when you have questions visit the <a href="http://developer.xojo.com/home">Xojo Dev Center</a> for documentation, examples, tutorials and more. Or ask the Xojo community on the <a href="https://forum.xojo.com">Forums</a>.</p>
<p><em>Javier Rodri­guez has been the Xojo Spanish Evangelist since 2008, he’s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of <a href="http://www.aprendexojo.com">AprendeXojo.com</a> and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app, among others.</em></p>
<p>*<a href="http://www.aprendexojo.com/2017/01/textfield-introduccion-de-texto/">Read this post in Spanish</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
