Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
on closeField
if fld "field2" is empty then
focus on fld "field2"
else
if fld "field3" is empty then
focus on fld "field3"
else
if fld "field4" is empty then
focus on fld "field4"
else
focus on fld "field5"
end if
end if
end if
end closeField
This works great! in livecode, however when it is saved as a windows stand alone application it does not work.
Does anyone have any other Ideas for me that wight work.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
In a standalone windows environment the script is ignored most of the time and it just advances to the next field like the script wasnt there at all. from field1 to field2 and from field2 to field3 and so on.
This code works better, but not what I want because it makes it harder to change the value in a field.
local sFlds = "fld1,fld2,fld3,fld4,fld5" -- use the real field names here
on tabKey
if "field" is not in the name of the target then exit tabKey
if target = "" then pass tabKey
selectNextEmptyFld
end tabKey
on selectNextEmptyFld
put the short name of the target into tCurFld
put itemOffset(tCurFld,sFlds) into tStart
repeat with x = tStart to the number of items in sFlds
put item x of sFlds into tFldName
if fld tFldName = empty then
select text of fld tFldName
exit repeat
end if
end repeat
end selectNextEmptyFld
Note that this is one case where using "the" matters. "The target" and "target" are different things.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Actually, the above script may not be exactly what you want. What do you want it to do if the selected field is already empty? Right now it uses the normal tab behavior. Also, it doesn't wrap around, but your example didn't do that either.
If you want the selection to stay in an empty field without moving, remove the second line of the tabKey handler.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
local sFlds = "fld1,fld2,fld3,fld4,fld5" -- use the real field names here
on tabKey
if "field" is not in the name of the target then exit tabKey
-- if target = "" then pass tabKey
selectNextEmptyFld
end tabKey
on selectNextEmptyFld
put the short name of the target into tCurFld
put itemOffset(tCurFld,sFlds) into tStart
if tStart = the number of items in sFlds and fld (item tStart of sFlds) <> "" then
put 1 into tStart
end if
repeat with x = tStart to the number of items in sFlds
put item x of sFlds into tFldName
if fld tFldName = empty then
select text of fld tFldName
exit repeat
end if
end repeat
end selectNextEmptyFld
Maybe that will get you close.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com