Android app first field already has focus but no onscreen kb
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Android app first field already has focus but no onscreen kb
Issue: In the BMI Calculator app from the getting started tutorial when it launches on my Samsung S7 Edge physical device, the first field has the focus but the keyboard is not displayed. If I tap the field nothing happens. If I tap the next field the keyboard comes up and I can enter text/numbers and then select the first field and the keyboard stays and I can then perform input.
I'm trying to figure out how not to have the app have focus on any field on the stack until the user physically selects the field at which time the keyboard would be displayed for input. At least that is what I think I want to accomplish.
Any pointers appreciated.
About me:
I'm completely new to LiveCode and have been learning about it via the BMI Calculator tutorial and reading through the documentation resources, LC dictionary and forum. I'm testing out the latest LC 8 RC1. With the outdated documentation I figured out how to install Android Studio 2.1 and download the Android 4.0.3 SDK and libraries supported by LC 8 RC1, then build the BMI app and fill out the settings for an Android standalone app and create it and install and run it successfully on my physical device. Whew! What an accomplishment it seems!
I'm trying to figure out how not to have the app have focus on any field on the stack until the user physically selects the field at which time the keyboard would be displayed for input. At least that is what I think I want to accomplish.
Any pointers appreciated.
About me:
I'm completely new to LiveCode and have been learning about it via the BMI Calculator tutorial and reading through the documentation resources, LC dictionary and forum. I'm testing out the latest LC 8 RC1. With the outdated documentation I figured out how to install Android Studio 2.1 and download the Android 4.0.3 SDK and libraries supported by LC 8 RC1, then build the BMI app and fill out the settings for an Android standalone app and create it and install and run it successfully on my physical device. Whew! What an accomplishment it seems!
Re: Android app first field already has focus but no onscree
Hi,
quick & dirty:
Make another field (may be 1x1 pixel) that gets the focus when going to this card?
Before the one you want to type in?
Have fun!
quick & dirty:
Make another field (may be 1x1 pixel) that gets the focus when going to this card?
Before the one you want to type in?
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: Android app first field already has focus but no onscree
Hi @gaanthony and welcome to the forum! Yes this can be an irritating behaviour on mobile devices and there are several ways to manage it (Axwald has already shown you one).
My own preference is to manage the 'traversalOn' property of the field or fields in question. This means that whilst the card is opening no message is sent to trigger the on-screen keyboard, and by the time a user wants to enter some text the field (and on-screen keyboard) is ready and waiting...
But that is just my way (I don't really fancy the idea of dummy fields), others here will have their own favourite way of doing things...
My own preference is to manage the 'traversalOn' property of the field or fields in question. This means that whilst the card is opening no message is sent to trigger the on-screen keyboard, and by the time a user wants to enter some text the field (and on-screen keyboard) is ready and waiting...
Code: Select all
on preOpenCard
setTraversalOff
end preOpenCard
on openCard
send setTraversalOn to me in 750 milliseconds
end openCard
on setTraversalOff
set the traversalOn of fld "fldTextEntry" to false
end setTraversalOff
on setTraversalOn
set the traversalOn of fld "fldTextEntry" to true
end setTraversalOn
"...this is not the code you are looking for..."
Re: Android app first field already has focus but no onscree
Great. Thank you both for the pointers.
Re: Android app first field already has focus but no onscreen kb
Dave Kilroy - have you used your traversalOn method for native android controls such as a multiline input field created by
The dictionary doesn't say this property can be set for native android controls as far as I can see...
Thanks.
Code: Select all
mobileControlCreate "multiline", "myMultiLineTextInput"
Thanks.
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: Android app first field already has focus but no onscreen kb
Hi @jim1001 - yep it works for Android for single line inputs, however have never tried multi-line so can't confirm that (should think it would be the same as single line?)
EDIT: replied too quick, had a look at code I actually use-
So my handler setTraversalOn sets the traversalOn of my ordinary LiveCode fields to true (I also have LiveCode fields for when the app is used by desktops - what I should probably do is to create relevant controls depending on the platform - but it works...)
SECOND EDIT: and my 'inputCreate' handler creates mobile input controls...
EDIT: replied too quick, had a look at code I actually use-
Code: Select all
on openCard
if isMobile() then
send setTraversalOn to me in 500 millisecs
send "inputCreate ncFirstName" to me in 650 millisecs
send "inputCreate ncLastName" to me in 700 millisecs
end if
end openCard
SECOND EDIT: and my 'inputCreate' handler creates mobile input controls...
"...this is not the code you are looking for..."
Re: Android app first field already has focus but no onscreen kb
Dave,
Many thanks for replying.
At the moment I can't even focus on the Android native mobile field when the card opens. My code is
Many thanks for replying.
OK - so what is your code to set traversalOn for Android native mobile fields? I thought you had to use mobileControlSet for them, no?So my handler setTraversalOn sets the traversalOn of my ordinary LiveCode fields to true
At the moment I can't even focus on the Android native mobile field when the card opens. My code is
but the flashing cursor appears in another field when the card opens.on openCard
focus on nothing
mobileControlDo "nativeInputField", "focus"
end openCard
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: Android app first field already has focus but no onscreen kb
hi @jim1001- no the traversalOn stuff is only for LiveCode fields, native fields don't use that property. If you've got a keyboard appearing it sounds like you have a field somewhere on your card (maybe off screen) that has it's traversalOn property set...
Search it down and nuke (or manage) that setting!
Kind regards
Dave
EDIT: other properties of fields to check are: lockText, autoHilite
Search it down and nuke (or manage) that setting!
Kind regards
Dave
EDIT: other properties of fields to check are: lockText, autoHilite
"...this is not the code you are looking for..."
Re: Android app first field already has focus but no onscreen kb
Dave, Thanks for latest reply. My wish is for the card to open with the native Android input field in focus and the keyboard visible. I can't make that happen at the moment. Not a major issue though - once the user clicks in the input field the keyboard appears as expected (& desired). I may have more of a play around...
All the best, Jim
All the best, Jim
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Location: Plymouth, UK
- Contact:
Re: Android app first field already has focus but no onscreen kb
Oh I see - try something like
However, depending on whether you are using any visual effects when entering your card (such as "push right") you'll probably want to delay when the keyboard appears slightly to let the visual effect finish - which you can do by sending commands 'in time'
Code: Select all
mobileControlDo "myTextInput","focus"
"...this is not the code you are looking for..."