Android Keyboard - Using "Sentence" Option.

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Googie85
Posts: 226
Joined: Tue Aug 05, 2014 10:07 am

Android Keyboard - Using "Sentence" Option.

Post by Googie85 » Thu May 29, 2025 8:08 am

Hii Guys!

I have in the past viewed a way to set the Android keyboard to a "Sentence" option. Essentially when a key is pressed, the character will automatically set the case to uppercase. I have searched the dictionary for "Keyboard" but can't seem to find the information I need.

Any help is greatly appreciated!

Many Thanks,

Matt.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Android Keyboard - Using "Sentence" Option.

Post by richmond62 » Thu May 29, 2025 8:30 am

I think you need to look at toUpper.
-
SShot 2025-05-29 at 10.37.43.png
-

Code: Select all

on keyDown KD
   put KD into KEYD
   put toUpper(KEYD) after fld "ff"
end keyDown
Attachments
Upper Case.livecode.zip
Stack
(4.02 KiB) Downloaded 187 times
Last edited by richmond62 on Thu May 29, 2025 8:48 am, edited 2 times in total.

Googie85
Posts: 226
Joined: Tue Aug 05, 2014 10:07 am

Re: Android Keyboard - Using "Sentence" Option.

Post by Googie85 » Thu May 29, 2025 8:31 am

I have tried that. I would like to show a Capital on the keyboard also.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Android Keyboard - Using "Sentence" Option.

Post by richmond62 » Thu May 29, 2025 8:40 am

I don't think LiveCode can control aspects of an operating system external to itself.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 3:20 pm

Googie85:

Isn't it the case, using the "sentence" idea you mentioned, that only the first character should be capitalized? In other words, if you are creating a document and type a period and then a space, is it that you want the next character to automatically be capitalized? That can be done under script control, and you do not have to change the keyboard. In the script of the field of interest:

Code: Select all

on rawKeyUp tkey
   if char - 3 to - 2 of me is ". " then put toUpper(numToChar(tkey)) into the last char of me
end rawKeyUp
Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 3:30 pm

All.

I used the "rawKeyUp" message in the above field handler because I cannot detect the "keyUp" message at all. That would be a simpler handler. If I try, I can see "keyDown", no problem. This is in a new stack with a single field. Just me again? :cry:

Restarting LC does not help.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Android Keyboard - Using "Sentence" Option.

Post by richmond62 » Thu May 29, 2025 3:45 pm

That WILL capitalise the first letter of all the sentences EXCEPT for the first one.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 4:06 pm

Richmond.

I was making a point, not building the OP's project. So:

Code: Select all

on rawKeyUp tkey
  if char  - 3 to - 2 of me is ". " or the length of me = 1 then
     put toUpper(numToChar(tkey)) into the last char of me
  end if
end rawKeyUp
Thinking along those lines, one might also allow two or more spaces after the period. And what happens after a hard return? That sort of thing.

And any thoughts on the fact that I can no longer trap "keyUp"?

Craig
Last edited by dunbarx on Thu May 29, 2025 8:18 pm, edited 2 times in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10080
Joined: Fri Feb 19, 2010 10:17 am

Re: Android Keyboard - Using "Sentence" Option.

Post by richmond62 » Thu May 29, 2025 4:17 pm

And any thoughts on the fact that I can no longer trap "keyUp"?
No.

I am 'stuck' at 9.6.3. 8)

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by stam » Thu May 29, 2025 4:37 pm

dunbarx wrote:
Thu May 29, 2025 4:06 pm
Richmond.

I was making a point, not building the OP's project. So:

Code: Select all

on rawKeyUp tkey
  if char  - 3 to - 2 of me is ". " or the length of me = 1 then
     put toUpper(numToChar(tkey)) into the last char of me
  end if
end rawKeyUp
And any thoughts on the fact that I can no longer trap "keyUp"?

Craig
mouseDown and mouseUp make sense, because if you're in mouseDown and the mouse moves out of the target area, mouseUp may have a different effect.

However, I don't understand why you would want to do this for pressing keys... it's not like a different action may be performed on keyUp.

But in any case, you need to pass the keyDown message to use the keyUp message. This makes your code work:

Code: Select all

on keydown
    pass keydown
end keydown

on keyUp pKeyName
    if char  - 3 to - 2 of me is ". " or the length of me = 1 then
        put toUpper(pKeyName) into the last char of me
    end if
end keyUp

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 324
Joined: Sat Aug 16, 2008 9:48 am
Contact:

Re: Android Keyboard - Using "Sentence" Option.

Post by SWEdeAndy » Thu May 29, 2025 5:07 pm

Googie85 wrote:
Thu May 29, 2025 8:08 am
I have in the past viewed a way to set the Android keyboard to a "Sentence" option. Essentially when a key is pressed, the character will automatically set the case to uppercase. I have searched the dictionary for "Keyboard" but can't seem to find the information I need.
Search for autoCapitalizationType in the dictionary.

It's a property of the native android field widget. It seems the widget must be loaded for the entry to show up in the Dictionary.

Code: Select all

set the autoCapitalizationType of widget "Android Field" to "sentences"
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 6:00 pm

Stam.
But in any case, you need to pass the keyDown message to use the keyUp message.
If I do not have a keyDown handler at all, that message is automatically passed to the engine at every keypress. It never occurred to me that such a thing was (should be) necessary. Explicitly doing so in a handler should do nothing additional.

I tried it anyway; it does not work.

But if you have a keyDown handler does it make keyUp work? And if you do not, it does not either? I don't understand this.

All my work is in the field script.

Craig
Last edited by dunbarx on Thu May 29, 2025 6:23 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 6:21 pm

Stam.
mouseDown and mouseUp make sense, because if you're in mouseDown and the mouse moves out of the target area, mouseUp may have a different effect.

However, I don't understand why you would want to do this for pressing keys... it's not like a different action may be performed on keyUp.
Yes, the mouse can change its environment between mouseDown and mouseUp. That is the reason behind "mouseRelease", to always remember the mouseDown target.

But it is not I who is concerned with pressing keys, it is the OP. I am not even sure I answered his needs.

Googie85?

My first handler was with "keyUp". But when that failed to even respond I went to "rawKeyUp" along with the deprecated "numTo"Char" function.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Android Keyboard - Using "Sentence" Option.

Post by dunbarx » Thu May 29, 2025 8:27 pm

Richmond.
I am 'stuck' at 9.6.3.)
Does that matter? It might, if this is a regression, though I doubt it.

Nobody seems upset at this, so I think I will start a new thread...

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android Keyboard - Using "Sentence" Option.

Post by jacque » Fri May 30, 2025 4:11 pm

This isn't a LC thing, it's a keyboard setting. Which keyboard are you using? I use SwiftKey, and the option is in the keyboard settings. Are you using the native Google keyboard?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply