Escribir en un field en mayúsculas

De nuevo Bedelludrica. Por mas vueltas que le doy, no consigo hacer en un field que he colocado se escriba siempre en mayúsculas. Necesito que independientemente de como esté el bloqueo de mayúsculas escriba en mayúsculas. Si me puedes ayudar te lo agradezco.

1 respuesta

Respuesta
1
Bedes usar este behaviour. Es muy sencillo de usar. Solo se lo debes vincular al texto y elegir entre mayusculas o minusculas.
-- DESCRIPTION --
On getBehaviorDescription me
return \
"FORCE CASE" & RETURN & RETURN & \
"Attach this behavior to an editable Field or Text member to convert all input either to UPPERCASE or to lowercase characters." & RETURN & RETURN & \
"This behavior is not suitable for accented letters such as âéïõù. " & \
"Use the more comprehensive 'Filter Input Characters' behavior for this." & RETURN & RETURN & \
"PERMITTED MEMBER TYPES:" & RETURN & \
"Field and Text members" & RETURN & RETURN & \
"PARAMETERS:" & RETURN & \
"* Choose between UPPERCASE or lowercase"
end getBehaviorDescription
on getBehaviorTooltip me
return \
"Use with Field and Text members." & RETURN & RETURN & \
"Convert all standard keyboard input to either UPPERCASE or lowercase."
end getBehaviorTooltip
-- NOTES FOR DEVELOPERS --
-- ASCII stands for American Standard Code for Information Interchange. It is
-- a code which gives an integer value between 0 and 127 to all the letters and
-- punctuation marks used in American English.
-- You can use Lingo to find the ASCII number for any character by using the
-- charToNum() function. For example:
--
-- Put charToNum ("A")
-- -- 65
-- Put charToNum ("a")
-- -- 97
--
-- What you see as "A" on the screen, the computer thinks of as 1000001, or 65
-- In binary code.
-- To convert an uppercase letter like "A" to its lowercase equivalent, you
-- Simply add 32 to charToNum("A"), and then use the numToChar() function to
-- Convert back to a letter.
-- This is what happens in the middle section of the ForceCase handler. The
-- First section of the handler simply leaves Director to deal with any non-
-- Alphabetical or accented characters, and any characters that are already in
-- the correct case.
-- The third section of the handler is the ForceCase most complex. It takes
-- Over from Director to place the converted character at the right point in
-- The editable member. The complexity arises from the fact that one or more
-- characters may be selected. If this is the case, the converted character
-- Must replace the selection. When Lingo places a converted character in the
-- The editable member, Director is unaware that the insertion point should
-- Move. The line "set the selStart to startChar + 1" jogs Directors memory.
-- Without it, converted characters would appear from right to left: words
-- Would appear backwards on the screen: teg uoy tahw si ees uoy tahw.
-- HISTORY --
-- 2 October 1998: written for the D7 Behaviors Palette by James Newton
-- 16 November 1998: ErrorAlert modified. Fixed for Text members.
--
-- Modified 10 January, 2000 by Tom Higgins: added the isOKToAttach
-- and resolve event handlers, removed redundant error checking.
-- PROPERTIES --
Property spriteNum
-- Author-defined parameters
Property myUpperCase
-- internal properties
Property myMember
Property myTextFlag
-- EVENT HANDLERS --
on beginSprite me
myUpperCase = resolve(myUpperCase)
Initialize me
end beginSprite
on resolve (prop)
case prop of
myUpperCase:
choicesList = ["lowercase", "UPPERCASE"]
lookup = [#lowercase, #UPPERCASE]
end case
return lookup[findPos(choicesList, prop)]
end resolve
on keyDown me
ForceCase me
end keyDown
-- CUSTOM HANDLERS --
on Initialize me -- sent by beginSprite
myMember = sprite(me.spriteNum).member
myTextFlag = (myMember.type = #text)
-- Convert to boolean
myUpperCase = (myUpperCase = #UPPERCASE)
end Initialize
on ForceCase me
theKey = the key
keyNum = charToNum (theKey)
-- let non-alpha characters pass
if keyNum < 65 or keyNum > 122 then pass
if keyNum > 90 and keyNum < 97 then pass
-- let the correct case pass
if keyNum < 97 and myUpperCase then pass
if keyNum > 90 and not myUpperCase then pass
-- Convert case...
if keyNum < 97 then
-- UPPERCASE to lowercase
theKey = numToChar (keyNum + 32)
else
-- lowercase to UPPERCASE
theKey = numToChar (keyNum - 32)
end if
-- ... and insert character "manually"
Insert me, theKey
end ForceCase
on Insert me, theKey -- sent by Filter
startChar = the selStart
if startChar = the selEnd then
if myMember.Type = #field then
put theKey after char startChar of field myMember
else -- #text member
theText = myMember.text
put theKey after char startChar of theText
myMember.text = theText
end if
else
myMember.char[(startChar + 1)..the selEnd] = theKey
end if
the selEnd to startChar + 1
the selStart to startChar + 1
dontPassEvent
end Insert
-- AUTHOR-DEFINED PARAMETERS --
on isOKToAttach (me, aSpriteType, aSpriteNum)
case aSpriteType of
#graphic:
return getPos([#field, #text], \
sprite(aSpriteNum).member.type) <> 0
#script:
return FALSE
end case
end isOKToAttach
on getPropertyDescriptionList me
return \
[ \
#myUpperCase: \
[ \
#comment: "Set all input to", \
#format: #string, \
#range: ["lowercase", "UPPERCASE"], \
#default: "lowercase" \
] \
]
end getPropertyDescriptionList

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas