Yup, I'm guessing (based on gut feels) that it has something to do with how the non-native fields pass information to the keyboard or how the soft keyboard logics pass their 'info' to the fields. Since it seems like the non-native fields create a new "variable" for their strings every time it get's focus while not considering what already existed and that probably causes the other issues as well (if what I'm feelstimating is even remotely correct).
(Btw, I'm dealing with lenovo tablets and neither 'fix' managed to make it work consistently.)
Regardless, the fix might come never and even then it'd require moving to a new version which is a huge gamble because every new version of livecode (for me) requires setting up all the android dependencies from scratch and then it'll work for only that version, not the older ones.
So I just went with the native fields, kinda.
Wrote a script that overlays all the fields on that specific card with mobileControls if you add a custom prop "androidInput" and set it to true.
Code: Select all
--card script
/*on preOpenCard
if the environment is "mobile" then
set the visible of fld "Mobiler" to false
send "OverlayFields" to fld "Mobiler"
end if
end preOpenCard
on closeCard
if the environment is "mobile" then
send "DeleteFields" to fld "Mobiler"
end if
end closeCard*/
--non-native field script sample
/*on focusIn
answer "inputBeginEditing/focusIn"
end focusIn
on focusOut
answer "inputEndEditing/focusOut"
end focusOut
on textChanged
answer "textChanged" && the innerText of me
end textChanged
on rawKeyDown k
if (k = "65293") then answer "rawKeyDown" && the innerText of me
end rawKeyDown*/
local controlAssociations
on DeleteFields
if (the last line of the keys of controlAssociations is not 0) then
repeat with n = 1 to (the num lines in the keys of controlAssociations/3)
set the text of controlAssociations[n,"non-native"] to the innerText of controlAssociations[n,"non-native"]
mobileControlDelete controlAssociations[n,"native"]
end repeat
end if
put empty into controlAssociations
end DeleteFields
on OverlayFields
lock screen
if (the environment is not "mobile") then exit OverlayFields
if (controlAssociations is not empty) then
answer "Fields created already"
exit OverlayFields
end if
put 1 into counter
repeat with x = 1 to the num of controls in this card
if ("field" is among the words of the long name of control x of this card AND \
the control x of this card is not me AND \
the androidInput of control x of this card is true) then
--create the overlay
if (the textSize of control x of this card is empty) then put 12 into tHeight
else put the textSize of control x of this card into tHeight
if (the height of control x of this card > tHeight*1.9) then
put "multiline" into inputType
put "default" into returnKeyType
else
put "input" into inputType
put "done" into returnKeyType
end if
put "inputControl_" & counter into controlAssociations[counter, "native"]
put the long id of control x of this card into controlAssociations[counter, "non-native"]
get inputCreator("inputControl_" & counter, inputType, controlAssociations[counter, "non-native"], "FALSE", "TRUE", "FALSE", "none", "default", returnKeyType, "red", "left", tHeight)
set the innerText of controlAssociations[counter, "non-native"] to the text of controlAssociations[counter,"non-native"]
mobileControlSet controlAssociations[counter,"native"], "text", the text of controlAssociations[counter, "non-native"]
set the text of controlAssociations[counter,"non-native"] to empty
if (the script of control x of this card is not empty) then
put the script of control x of this card into tempScript
put "0000" into controlAssociations[counter, "messages"]
-- check whether to pass focusIn
if (matchText(tempScript, "on focusIn")) then put "1" into char 1 of controlAssociations[counter, "messages"]
-- check whether to pass inputEndEditing/focusOut
if (matchText(tempScript, "on focusOut")) then put "1" into char 2 of controlAssociations[counter, "messages"]
-- check whether to textChanged/textChanged
if (matchText(tempScript, "on textChanged")) then put "1" into char 3 of controlAssociations[counter, "messages"]
-- check whether to pass returnKey/rawKeyDown
if (matchText(tempScript, "on rawKeyDown")) then put "1" into char 4 of controlAssociations[counter, "messages"]
end if
add 1 to counter
end if
end repeat
unlock screen
end OverlayFields
--maps to "focusIn"
/*on focusIn
if (the evinronment is "mobile") then put the innerText of me into theText
else put the text of me into theText
--do things where "theText" is the text of the fld
end focusIn*/
on inputBeginEditing
if (the last line of the keys of controlAssociations is not 0) then
repeat with n = 1 to (the num lines in the keys of controlAssociations/3)
if (mobileControlTarget() is controlAssociations[n,"native"] AND \
char 1 of controlAssociations[n,"messages"] is "1") then
put mobileControlGet(controlAssociations[n, "native"], "text") into k
set the innerText of controlAssociations[n,"non-native"] to k
send "focusIn" to controlAssociations[n,"non-native"]
end if
end repeat
end if
end inputBeginEditing
--maps to "focusOut"
/*on focusOut
if (the evinronment is "mobile") then put the innerText of me into theText
else put the text of me into theText
--do things where "theText" is the text of the fld
end focusOut*/
on inputEndEditing
if (the last line of the keys of controlAssociations is not 0) then
repeat with n = 1 to (the num lines in the keys of controlAssociations/3)
if (mobileControlTarget() is controlAssociations[n,"native"] AND \
char 2 of controlAssociations[n,"messages"] is "1") then
put mobileControlGet(controlAssociations[n, "native"], "text") into k
set the innerText of controlAssociations[n,"non-native"] to k
send "focusOut" to controlAssociations[n,"non-native"]
end if
end repeat
end if
end inputEndEditing
--maps to "textChanged"
/*on textChanged
if (the evinronment is "mobile") then put the innerText of me into theText
else put the text of me into theText
--do things where "theText" is the text of the fld
end textChanged*/
on inputTextChanged
if (the last line of the keys of controlAssociations is not 0) then
repeat with n = 1 to (the num lines in the keys of controlAssociations/3)
if (mobileControlTarget() is controlAssociations[n,"native"] AND \
char 3 of controlAssociations[n,"messages"] is "1") then
put mobileControlGet(controlAssociations[n, "native"], "text") into k
set the innerText of controlAssociations[n,"non-native"] to k
send "textChanged" to controlAssociations[n,"non-native"]
end if
end repeat
end if
end inputTextChanged
--maps to "rawKeyDown 65293"
/*on rawKeyDown k --non-native control script
if (k = "65293") then
--do things
end if
end rawKeyDown*/
on inputReturnKey
if (the last line of the keys of controlAssociations is not 0) then
repeat with n = 1 to (the num lines in the keys of controlAssociations/3)
if (mobileControlTarget() is controlAssociations[n,"native"] AND \
char 4 of controlAssociations[n,"messages"] is "1") then
put mobileControlGet(controlAssociations[n, "native"], "text") into k
set the innerText of controlAssociations[n,"non-native"] to k
send "rawKeyDown" && "65293" to controlAssociations[n,"non-native"]
end if
end repeat
end if
end inputReturnKey
--slightly modified version of http://forums.livecode.com/viewtopic.php?f=49&t=26810#p139691 by "quailcreek"
function inputCreator pName, pKind, pRect, pAutoClear, pAutoFit, pAutoCap, pAutoCorrect, pKeyboardType, pReturnKey, pBackgroundColor, ptextAlign, pfontSize
mobileControlCreate pKind, pName
mobileControlSet pName, "visible", true
if (pKind is "input") then
put the rect of pRect into tRect
put item 2 of tRect - 6 into item 2 of tRect
put item 4 of tRect + 8 into item 4 of tRect
mobileControlSet pName, "rect", tRect
else
mobileControlSet pName, "rect", the rect of pRect
end if
mobileControlSet pName, "opaque", false
mobileControlSet pName, "autoFit", pAutoFit
mobileControlSet pName, "autoClear", pAutoClear
mobileControlSet pName, "autoCapitalizationType", pAutoCap
mobileControlSet pName, "autoCorrectionType", pAutoCorrect
mobileControlSet pName, "keyboardType", pKeyboardType
mobileControlSet pName, "returnKeyType", pReturnKey
mobileControlSet pName, "clearButtonMode", "while editing"
mobileControlSet pName, "borderStyle", "none"
mobileControlSet pName, "fontName", "Arial"
mobileControlSet pName, "textColor", the foregroundColor of pRect
mobileControlSet pName, "backgroundColor", pBackgroundColor
mobileControlSet pName, "textAlign", ptextAlign
mobileControlSet pName, "Alpha", 0
mobilecontrolSet pName, "fontSize", pfontSize
if (pKind is "input") then
mobilecontrolSet pName, "scrollingEnabled", false
mobileControlSet pName, "multiline", false
end if
end inputCreator
I plan on finishing it properly, but just in case I don't I'm posting it here for future people.
Anywho, the basic gist of it is that it finds the fields you want to 'mobilize' (on the card you place the "mobiler" fld) and then creates the input controls and passes on the messages to the (parent) non-native fields. This way you can test out whether something works in the ide and the script takes care of the message handling while running it on android.
To use it, you c+p the card stuff to your card script, the fld stuff to your field that you've added the custom prop (androidInput = true) or
Code: Select all
set the androidInput of fld "Field" to true
and create a new fld named "Mobiler" to which you c+p the whole thing as it's what creates the Inputs, receives all the messages and will pass the messages to the non-native fields.