Android Keyboard Activation Issue

Livecode XAC lc-developer at xpertassist.com
Thu Jan 12 12:41:07 EST 2017


Andrew,

I'm doing the same type of thing, but because I have multiple input fields
on the card, I send the inputCreateTSM when the user selects the field.

Here is the function that I'm using to create the Native Control when the
field is selected.

<CONTROL>
on inputCreatorWide pName, pFld, pContent, pKeyboardType, pAutoCap,
pAutoCorrect, pReturn, pDataDetect
   
   if environment() is not "mobile" then exit inputCreatorWide
   
   put the uOS of this stack into tOsType
   
   if tOsType = "android" then
      get inputCleanUp()
   end if
      
   if pFld contains "stack" then   -- removed the stack part of the field
identifier
      put wordOffset("stack",pFld) into tWord
      put word 1 to (tWord -2) of pFld into pFld
   end if
   
   get setInputFieldName( pFld )  -- Save the active Input Field
   
   get moveToVisibleArea( pFld )    -- Make sure the field is within the
visible area of the display.

   put the rect of pFld into tSize   
   put the height of pFld into tHeight
   put the width of pFld into tWidth
   
   if tOsType = "android" then
      set the itemdel to ","
      add (tHeight/2) to item 4 of tSize -- Increase the field size
      if tWidth < 50 then
         add (100 - tWidth) to item 3 of tSize
      end if
   end if
   
   mobileControlCreate "input", pName
   mobileControlSet pName, "rect", tSize -- standard for all controls
   mobileControlSet pName, "visible", "True"  -- standard for all controls
   mobileControlSet pName, "text", pContent
   
   if tOsType = "ios" then
      mobileControlSet pName, "alpha", "255"
      mobileControlSet pName, "backgroundColor", "240,248,255,255"
   end if
   
   -- Font Size
       if tHeight >60 then
         mobileControlSet pName, "fontSize", 20
      else if tHeight > 50 AND tHeight <= 60 then
         mobileControlSet pName, "fontSize", 21
      else if tHeight > 40 AND tHeight <= 50 then
         mobileControlSet pName, "fontSize", 17
      else
         mobileControlSet pName, "fontSize", 14
      end if
   
   mobileControlSet pName, "textAlign", "left"
   
   if pKeyboardType is not Empty then 
      if tOsType = "ios" AND pKeyboardType = "number" OR pKeyboardType =
"numeric" then
         mobileControlSet pName, "keyboardType", "numeric"
      else
         mobileControlSet pName, "keyboardType", pKeyboardType
      end if     
   else
      mobileControlSet pName, "keyboardType", "default"
   end if
   
   if pReturn is not Empty then 
      mobileControlSet pName, "returnKeyType", pReturn
   else
      mobileControlSet pName, "returnKeyType", "default"
   end if
   
   if pAutoCap is not Empty then 
      mobileControlSet pName, "autoCapitalizationType", pAutoCap
   else
      mobileControlSet pName, "autoCapitalizationType", "none"
   end if
   
   if pAutoCorrect is not Empty then 
      mobileControlSet pName, "autoCorrectionType", pAutoCorrect
   else
      mobileControlSet pName, "autoCorrectionType", "default"
   end if
      
   -- Set the field parameters for iOS
   
   if tOsType = "ios" then
      mobileControlSet pName, "font", "arial"
      mobileControlSet pName, "autoFit", true
      mobileControlSet pName, "minimumFontSize", "14"
      mobileControlSet pName, "autoClear", false
      mobileControlSet pName, "borderStyle", "line"
      mobileControlSet pName, "manageReturnKey", false
      mobileControlSet pName, "keyboardStyle", "default"
      mobileControlSet pName, "clearButtonMode", "unless editing"
   end if
      
   -- Focus on the Control
   mobileControlDo pName, "focus"             -- actually focus on the field
so the keyboard pops up
   
end inputCreatorWide
<END CONTORL>

Mine is more complex, but for some reason it will not bring up the Keyboard
on Android, but does on iOS.
Is the same behavior you are seeing?

Thanks for the response....
Dan

-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of Andrew Bell via use-livecode
Sent: Thursday, January 12, 2017 10:48 AM
To: use-livecode at lists.runrev.com
Cc: andrew at midwestcoastmedia.com
Subject: Re: Android Keyboard Activation Issue

Here is a card script I'm currently using that seems to work in an
iOS/Android app I have now:

on preOpenCard
       inputCreateTsm
end preOpenCard

on inputCreateTSM
    put the rect of graphic "tsmRectangle" into tThisRect
    # do some math to visually accommodate a roundedRect with innerShadow
    add 15 to item 1 of tThisRect
    subtract 10 from item 3 of tThisRect
    mobileControlCreate "input", "TSMinput"
    mobileControlSet "TSMinput", "rect", tThisRect
    mobileControlSet "TSMinput", "text", line 1 of gCurrentPrefs
    mobileControlSet "TSMinput", "keyboardType", "number"
    mobileControlSet "TSMinput", "fontSize", 21
    mobileControlSet "TSMinput", "fontName", "Roboto Light" -- iOS only
    mobileControlSet "TSMinput", "textAlign", "center"
    mobileControlSet "TSMinput", "visible", true
    # make sure the field has focus, which activates the keyboard
    mobileControlDo "TSMinput", "focus"
end inputCreateTSM


on closeCard
    # delete the native text input
    mobileControlDelete "TSMinput"
end closeCard



> Date: Thu, 12 Jan 2017 03:44:19 +0000
> From: "Daniel Pierce" <dpierce at xpertassist.com>
> To: "'Daniel Pierce via use-livecode'" <use-livecode at lists.runrev.com>
> Subject: Android Keyboard Activation Issue
> Message-ID:
> 	
> <0101015990c6b871-5fd4abdc-5e55-49b8-9a80-9c172ffe6fee-000000 at us-west-
> 2.amazonses.com>
>
> Content-Type: text/plain;	charset="us-ascii"
>
> List,
>
> I have developed a cross platform mobile app for iOS and Android using 
> LiveCode and it is working OK, but I continue to get a common 
> complaint from Android users that when they select a field the 
> keyboard does not activate like on other apps.
>
> This is not an issue on iOS because a when you create the Native Text 
> Box, you can send the command mobileControlDo <id> "focus" and the 
> keyboard is activated with a single touch to the text entry field.
>
> Android doesn't support this capability so the users needs to touch 
> the field to activate the Native Text Box and then touch it again to 
> bring up the keyboard.
>
> Has anyone found a way to bring up the virtual keyboard when the 
> Native Text Box has been created????
>
> Thanks for your advice.
> Dan



_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list