Text field focus - odd behaviour

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Posts: 7
Joined: Sat Aug 23, 2014 7:23 pm

Text field focus - odd behaviour

Post by stallik » Tue Oct 28, 2014 10:55 am

I have an app with a group containing a background graphic and a single field which can be edited by the user. The group moves off screen with a swipe action and at the same time, the contents of the field are saved to a local text file.
When the field is selected, the keyboard appears as expected and the data is saved and retrieved correctly. Problem occurs when the field is deselected and reselected. At that point, a data grid on the same card is selected instead of the field. Closing the card and reopening it allows me to select the correct field again.
Suspecting the save action, I disabled it but the issue remains. Behaviour is the same in simulator and device. Livecode 7.0 community
EDIT: problem seems to be associated with moving the group(closing) and moving again(opening)

group open script:
on mouseUp
set the vis of fld "promptright" to false
set the vis of graphic "promptbg" to false
move grp "prompt" to 165,187 in .5sec
end mouseUp

group close script:
local tStart, tEnd
on touchStart pID
  ## When the user touches the screen     
  put empty into tStart
  put empty into tEnd
end touchStart
on touchMove pID, x, y
if tStart is empty then        
put x into tStart
put x into tEnd
end if
end touchMove
on touchEnd
## Compare the x coordinates of the start and end point     
## This tells us the direction of the movement    
if tStart is not empty and tEnd is not empty then
if tStart > tEnd and tStart - tEnd > 100 then            
else if tStart < tEnd and tEnd-tStart > 100 then            
exit to top
end if
end if    
put empty into sCoordinateArray["start"]
put empty into sCoordinateArray["end"]
end touchEnd
on moveLeft
--Save Notes
 put specialfolderpath("documents") & "/" & the short name of this card & ".txt" into tDataToWrite
   put fld "notes" into URL("file:" & tDataToWrite)
focus on nothing
set the vis of fld "promptleft" to false
move grp "prompt" to -176,187 in .5sec
set the vis of fld "promptright" to true
set the vis of graphic "promptbg" to true
end moveLeft

text field script:
on closeField
focus on nothing
end closeField
on exitField
focus on nothing
end exitField

Posts: 7
Joined: Sat Aug 23, 2014 7:23 pm

Re: Text field focus - odd behaviour

Post by stallik » Tue Oct 28, 2014 3:06 pm

Ahh. seem to have found what the problem was - inherited from an issue with the datagrid which I'd sorted a long time ago and forgotten. The data grid grabs the focus unless I run a deselect script when I move my text field. Why, without the script, things work once but not subsequently will have to wait for another time but for now, i've got it working

Post Reply

Return to “iOS Deployment”