Keyboard input live parsing on native field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Keyboard input live parsing on native field

Post by trevix » Thu Jul 08, 2021 5:16 pm

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
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Keyboard input live parsing on native field

Post by SWEdeAndy » Fri Jul 09, 2021 2:52 pm

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?
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Keyboard input live parsing on native field

Post by trevix » Fri Jul 09, 2021 5:35 pm

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
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Keyboard input live parsing on native field

Post by SWEdeAndy » Fri Jul 09, 2021 9:03 pm

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.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Keyboard input live parsing on native field

Post by SWEdeAndy » Fri Jul 09, 2021 9:25 pm

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.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”