Page 1 of 1

Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 9:21 am
by davidmills
On my Android why does only the on returnInField work and yet none of the others do?
Thanks
Dave

Code: Select all

on openField
mobileSetKeyboardType "numeric"
end openField

on returnInField
   beep
   exit to top
end returnInField

on commaInField
   beep
   exit to top
end commaInField

on spaceInField
   beep
   exit to top
end spaceInField

end keyDown

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 9:59 am
by jmburnod
Hi Dave,

You can use keyup to do that

Code: Select all

on keyup pKey
   if pKey is in "abc" then
      beep
   else
      put pKey
   end if
end keyup
Have also a look to keydown, rawkeydown, rawkeyUp
Best regards
Jean-Marc

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 11:56 am
by SparkOut
Just to elaborate, the engine sends different messages when things happen. One of the engine messages is enterInField which is sent when the enter key is pressed in the field. There is no such message for comma, or most alphanumeric keys. So you need to use the more generalised messages as Jean-Marc says.

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 12:44 pm
by Klaus
Hi Dave,
davidmills wrote:On my Android why does only the on returnInField work and yet none of the others do?
the answer is quite simple: If it is not listed in the DICTIONARY (hint, hint!), then it is not build-in! 8)


Best

Klaus

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 1:25 pm
by davidmills
Thanks for all your replies. But I don't understand from the example what I'm supposed to replace my present script with, other than I presume the "abc" is the field name.
Thanks
Dave

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 2:01 pm
by jmburnod
Hi Dave
"abc" is the field name.
No that is a list of chars you want avoïd.

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 4:22 pm
by davidmills
Thanks and whilst is now working OK. Is there a way to remove the incorrect characters whilst still in the field other than doing a manual delete?
Dave

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 4:51 pm
by Thierry
davidmills wrote:Thanks and whilst is now working OK. Is there a way to remove the incorrect characters whilst still in the field other than doing a manual delete?
Dave
What about this:

Considering you don't want a, b and c characters:

Code: Select all

put replaceText( theText, "[abc]", empty)
Regards,

Thierry

Re: Restrict certain keyboard keys

Posted: Fri Apr 03, 2015 8:34 pm
by davidmills
Thank you Thierry. It's the comma and space I don't want, but where do I add your script line as I tried line 13 after beep?
Dave

Code: Select all

on openField
mobileSetKeyboardType "numeric"
end openField

on returnInField
   beep
   exit to top
end returnInField

on keyup pKey
   if pKey is in ", " then
   beep
   else
   put pKey
end if
end keyup