Page 1 of 1

Keyboard input live parsing on native field

Posted: Thu Jul 08, 2021 5:16 pm
by trevix
Having a mobile control field, on iOS and Android, is it possible to live parse the keyboard input, like avoid the user to enter spaces?
Or it is possible only when ending the editing, like this

Code: Select all

on inputEndEditing
     # handle the inputEndEdited message
     put word 1 to 5 of mobileControlGet(sControlID, "text") into tText --remove spaces outside
     replace " " with "" in tText --no spaces inside
     mobileControlSet sControlID, "text", tText
end inputEndEditin
"on KeyDown" doesn't work.
"On inputTextChanged" doesn't work.

Thanks for any help

Re: Keyboard input live parsing on native field

Posted: Fri Jul 09, 2021 2:52 pm
by SWEdeAndy
inputTextChanged should work for that. I've used it in a project to enable a save button as soon as the user types the first char.

The Dictionary says:
"The inputTextChanged message is sent to the object containing the script that created the text input control."

Where did you put the "on inputTextChanged" handler when you tested it?

Re: Keyboard input live parsing on native field

Posted: Fri Jul 09, 2021 5:35 pm
by trevix
if you mean this, it crashes the standalone on Android

Code: Select all

on inputTextChanged
     --     --   # handle the inputTextChanged message
     put mobileControlGet(sControlID, "text") into tText
     replace " " with "" in tText
     mobileControlSet sControlID, "text", tText
end inputTextChanged

Re: Keyboard input live parsing on native field

Posted: Fri Jul 09, 2021 9:03 pm
by SWEdeAndy
Oh, ok. Sounds like a an LC bug then maybe. If live parsing of a mobileControl and altering the content by script while editing it is not supported, it should at least be mentioned in the docs, which it isn't.

Unfortunately, I don't currently have a setup for testing Android deployment, so I can't test it at the moment. I could test on iOS, to see if it is a general mobile issue or just Android.

Re: Keyboard input live parsing on native field

Posted: Fri Jul 09, 2021 9:25 pm
by SWEdeAndy
I just quickly tested with iOS (in simulator, iPhone 11), and your script works perfectly there. It prevents entry of spaces while typing. No crashing.
So, seems to be an Android problem.