How do I force a key to enter just one character when being pressed?

Keith Clarke keith.clarke at clarkeandclarke.co.uk
Wed Jan 19 06:15:24 EST 2011


...how about using key-down, to trap the entered characters into a 'cache' variable and then on key-up, writing character 1 from that back into your target field/variable? 
 
On 19 Jan 2011, at 11:02, William de Smet wrote:

> Thanks John,
> 
> But with this script I limt the entry of the field to just one character.
> My 'problem' is dat when you keep a key pressed down more characters
> are entered.
> When you hold down the 'A' key AAAAAAAAAAA is entered.
> I wish to limit that. Just one entry of a key when being hold
> down/pressed al the time.
> 
> Any thoughts on this?
> 
> greetings,
> 
> William
> 
> 
> 
> 2011/1/19 John Dixon <dixonja at hotmail.co.uk>:
>> 
>> 
>> In the script of fld "text"...
>> 
>> on keyDown theKey
>>   if the number of chars of fld "text" > 0 then
>>      beep
>>      exit keyDown
>>   else
>>      put theKey into fld "text"
>>   end if
>> end keyDown
>> 
>>> Hi there,
>>> 
>>> I limit text entry of fld "text" with following code.
>>> 
>>> on keyDown pKey
>>>    if (the formattedHeight of fld "text" < the height of fld "text")
>>>   then
>>>   pass keyDown
>>>   end if
>>> end keyDown
>>> 
>>> One thing that I want to change now is a way to force a key to enter
>>> just one character after being pressed/hold down.
>>> Any thoughts on that?
>>> 
>>> greetings,
>>> 
>>> William
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list