New topic: auto capitalization
<http://forums.realsoftware.com/viewtopic.php?t=46535> Page 1 of 1 [ 15 posts ] Previous topic | Next topic Author Message carlbutler7 Post subject: auto capitalizationPosted: Sat Jan 12, 2013 7:59 am Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 how can i get text fields to auto capitalize all words typed into the field? thanks carl Top jakuno Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 8:07 am Joined: Fri Aug 31, 2012 3:56 pm Posts: 67 Sub Open() me.Mask = ">" End Sub Top carlbutler7 Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 11:11 am Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 where abouts would i put this code?jakuno wrote:Sub Open() me.Mask = ">" End Sub Top elChupete Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 11:16 am Joined: Fri Jun 05, 2009 11:50 am Posts: 328 Location: Hamburg, Germany put me.Mask = ">" in the textfield open event _________________ Best regards Stefan Mac OSX 10.8.1 on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3 Top carlbutler7 Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 12:14 pm Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 i got it i meant the first letter of the word capitalized, like a name field would result John Smith automatically thanks that info was helpful though Top simulanics Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 1:53 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 981 Location: Boiling Springs, SC Try this...(the TextField in the demo provided will automatically auto capitalize every word as the words are typed (or pasted)) Source Code: http://www.realstudiodevspot.com/demos/propercase.rbp Function: Function Propercase(Text As String, Spacers As String = "") As String Dim sp As Boolean = True Dim ch As String Text = Lowercase(Text) If Spacers = "" Then Spacers = " `~@#¦§£$%^&*()-_=+±[]{}\|,.<>/;:'ââââ°¹²³!?¡¿©®«»¼½¾'" + Chr(34) End If For i As Int32 = 1 To Len(Text) ch = Mid(Text, i, 1) If sp Then Text = Left(Text, i - 1) + Uppercase(ch) + Mid(Text, i + 1) End If sp = InStr(Spacers, ch) > 0 Next Return Text End Function or use a Regular Expression: :%s/\<\(.\)\([^[:space:][:punct:]]*\)\>/\u\1\2/g _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top jakuno Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 3:09 pm Joined: Fri Aug 31, 2012 3:56 pm Posts: 67 Live replace: Sub TextChange() dim start as integer = me.SelStart dim length as integer = me.SelLength dim words() as string = me.text.Split(" ") for i as integer = 0 to words.Ubound words(i) = Uppercase(words(i).Left(1)) + words(i).mid(2) next me.text = Join(words, " ") me.SelStart = start me.SelLength = length End Sub Top harriew Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 3:53 pm Joined: Fri Dec 01, 2006 3:09 pm Posts: 624 Location: Tennessee, USA Why not just use the Titlecase function in the TextChange event me.text = Titlecase(me.text) Top simulanics Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 4:23 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 981 Location: Boiling Springs, SC harriew wrote:Why not just use the Titlecase function in the TextChange event me.text = Titlecase(me.text) TitleCase does not handle hyphenated names or account for any words that have ~@#¦§£$%^&*()-_=+±[]{}\|,.<>/;:'ââââ°¹²³!?¡¿©®«»¼½¾' before or after them _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top jakuno Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 4:29 pm Joined: Fri Aug 31, 2012 3:56 pm Posts: 67 harriew wrote:Why not just use the Titlecase function in the TextChange event me.text = Titlecase(me.text)Because it's too easy Top simulanics Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 4:35 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 981 Location: Boiling Springs, SC jakuno wrote:harriew wrote:Why not just use the Titlecase function in the TextChange event me.text = Titlecase(me.text)Because it's too easy But doesn't work for "the book name" = "the Book Name" or vander-build = Vander-build or (the house-boat) = (the House-boat) or ¿hola como estas? = ¿hola Como Estas? and a million more _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top carlbutler7 Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 5:45 pm Joined: Tue Jan 08, 2013 8:27 pm Posts: 8 thanks very much, apreciate it Top harriew Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 6:03 pm Joined: Fri Dec 01, 2006 3:09 pm Posts: 624 Location: Tennessee, USA I suggested using Titlecase because the original posting stated that a way was desired that would uppercase the first letter of ALL words entered into the field. Titlecase does exactly that. Now, I fully realize that if the field is going to take names, book titles etc that there are many cases where you do not want every word to start with an uppercase character. And there are cases where you may want more than one letter in a word upper cased such as some Irish names. I simply threw Titlecase out there since noone else had mentioned it. After that it is up to the author of the code to decide which way is best for his/her project. Top npalardy Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 6:33 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7674 Location: Canada, Alberta, Near Red Deer Capitalization rules are horrid - they depend on linguistic norms that are VERY hard to put into code. Names are the worst. Should O'Hare be as I wrote it ? Or O'hare ? (I've seen both) And what about other names like MacDonald, McDonnough etc. None of the rules proposed so far account for those as the second capital is not following a punctuation mark. Then you get into names that start with apostrophes like 'Awarta and 'Ashira ICK _________________ My web site Great White Software RBLibrary.com REALbasic learning Top DaveS Post subject: Re: auto capitalizationPosted: Sat Jan 12, 2013 7:07 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4412 Location: San Diego, CA don't forget names with two capital letters and NO non-alphabetic characters McDonald for example. I run an internationals website, and had to over-ride some of my ProperCase code so as to no make some of my clients angry because their names were not handled correctly. (and my father-in-law is a McGrath... and I dang sure don't want to piss him off ) ) _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 15 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
