Forcing all capitals in a text field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Forcing all capitals in a text field
Can I I force all text in a field to be in all capitals?
Thanks!
iccs
Thanks!
iccs
Re: Forcing all capitals in a text field
one way would be to use the toUpper function. (in the dictionary) you can either wait for all input to complete and then change everything to upper, do using key events (keydown, or rawkeydown) or you could have it run every time the text changes in the field in any way. (including delete, returns, backspaces) using on textChanged. Or you could do it on closefield
if you use keyDown here is a simple example (placed in the field script) that might do what you wish.
if you use keyDown here is a simple example (placed in the field script) that might do what you wish.
Code: Select all
on keyDown pKey
-- make sure its a letter
if pKey is among the chars of "abcdefghijklmnopqrstuvwxyz" then
put toUpper(pKey) into pKey -- force the key to upper.
put pKey into the selection -- put it at the current insertion point
else
pass keydown -- otherwise just pass the key along as is.
end if
end keyDown
Re: Forcing all capitals in a text field
Sturgis.
Small point, and one I had to test myself, but only lower case letters are affected by this function.
The dictionary even says as much, which I read only after testing. Typical.
Craig
Small point, and one I had to test myself, but only lower case letters are affected by this function.
The dictionary even says as much, which I read only after testing. Typical.
Craig
Re: Forcing all capitals in a text field
Only reason its in an if statement is so that it doesn't needlessly run on anything but letters. Probably no discernable speed difference, but I figured 1 if check is (even if unnoticeably) faster than a function call and an insert into a field.
Is kinda pointless do do so trying to save unmeasurable time.
Is kinda pointless do do so trying to save unmeasurable time.
Re: Forcing all capitals in a text field
toUpper??
That has to be the worst LC command...wait no... good command, lousy notation.
charToUpper
caseToUpper
shiftCase
charShift
I could keep going with these
If there are LC beginners reading this, this is the only example I know of.
Simon
That has to be the worst LC command...wait no... good command, lousy notation.
charToUpper
caseToUpper
shiftCase
charShift
I could keep going with these

If there are LC beginners reading this, this is the only example I know of.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Forcing all capitals in a text field
This works great! However, I have another silly question. I already have an existing keyDown script (on keyDown var) in this field. How do I deal with more than one on mouseDown scripts in one field?sturgis wrote:one way would be to use the toUpper function. (in the dictionary) you can either wait for all input to complete and then change everything to upper, do using key events (keydown, or rawkeydown) or you could have it run every time the text changes in the field in any way. (including delete, returns, backspaces) using on textChanged. Or you could do it on closefield
if you use keyDown here is a simple example (placed in the field script) that might do what you wish.
Code: Select all
on keyDown pKey -- make sure its a letter if pKey is among the chars of "abcdefghijklmnopqrstuvwxyz" then put toUpper(pKey) into pKey -- force the key to upper. put pKey into the selection -- put it at the current insertion point else pass keydown -- otherwise just pass the key along as is. end if end keyDown
Re: Forcing all capitals in a text field
Depending on what is in the keydown, you can probably combine the two. Want to post your script?
Also, as dunbar (craig) pointed out, my script could be turned into a 1 liner since its silly to use a conditional in this CASE. (pun intended)
Post your current script, and most likely toUpper can be incorporated. (if not there are other ways to get it done.)
Also, as dunbar (craig) pointed out, my script could be turned into a 1 liner since its silly to use a conditional in this CASE. (pun intended)
Post your current script, and most likely toUpper can be incorporated. (if not there are other ways to get it done.)
Re: Forcing all capitals in a text field
On the other hand, that's the name of the same function in lots of languages, so many people will already know it. Besides SuperCard, it's in Java, Real Basic, C++, VB, and more. Same goes for toLower.Simon wrote:toUpper??
That has to be the worst LC command...wait no... good command, lousy notation.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Forcing all capitals in a text field
Here's my existing script:sturgis wrote:Depending on what is in the keydown, you can probably combine the two. Want to post your script?
Also, as dunbar (craig) pointed out, my script could be turned into a 1 liner since its silly to use a conditional in this CASE. (pun intended)
Post your current script, and most likely toUpper can be incorporated. (if not there are other ways to get it done.)
local tData
on mouseenter
put fld "theData" into tData
end mouseenter
on keydown var
put var after me
if me is among the words of tData then
get lineOffset(me,tData)
put word 2 of line it of tData into fld "output"
end if
end keydown
Re: Forcing all capitals in a text field
Change your keydown as follows:ICCS_User wrote:Depending on what is in the keydown, you can probably combine the two. Want to post your script?
Also, as dunbar (craig) pointed out, my script could be turned into a 1 liner since its silly to use a conditional in this CASE. (pun intended)
Post your current script, and most likely toUpper can be incorporated. (if not there are other ways to get it done.)
Code: Select all
local tData
on mouseenter
put fld "theData" into tData
end mouseenter
on keydown var
put toUpper(var) after me -- change this line to force the upper case.
if me is among the words of tData then
get lineOffset(me,tData)
put word 2 of line it of tData into fld "output"
end if
end keydown