Android Native Field Return Key

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Android Native Field Return Key

Post by jwtea »

Hello guys,
i got 2 different android native field in 1 card and i want field A to have this return key function and field B to have another return key function. Any idea how?

PS: The code to create my field

Code: Select all

on preopencard
   mobileControlCreate "input", "fieldA"
   mobileControlSet "fieldA", "rect", the rect of graphic "InputRect1"
   mobileControlSet "fieldA", "visible", true
   mobileControlSet "fieldA", "returnKeyType", next
   mobileControlDo "fieldA", "focus" , true
   
   mobileControlCreate "input", "fieldB"
   mobileControlSet "fieldB", "rect", the rect of graphic "InputRect2"
   mobileControlSet "fieldB", "visible", true
   mobileControlSet "fieldB", "returnKeyType", send
   mobileControlDo "fieldB", "focus" , true
end preopencard

on InputReturnKey
answer hello
end InputReturnKey
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Android Native Field Return Key

Post by Klaus »

Does it not work? Your script looks OK, but please put QUOTES around the returnkeytype:

Code: Select all

...
mobileControlSet "fieldA", "returnKeyType", "next"
...
mobileControlSet "fieldB", "returnKeyType", "send"
...
jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: Android Native Field Return Key

Post by jwtea »

Hello Klaus :D

I mean it worked for the type of returnKey but i want different returnKey function for fieldA and fieldB.

Example;

Code: Select all

on InputReturnKey
answer hello
end InputReturnKey
Both of the field returnKey answer hello but i want fieldA to answer "hello" and fieldB to answer goodbye.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Android Native Field Return Key

Post by Klaus »

Oh, misunderstood your question.
Sorry, no idea.
jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: Android Native Field Return Key

Post by jwtea »

Solution found!

Code: Select all

On inputReturnKey

if mobileControlTarget() is "fieldA" then
      answer "hello
   end if

if mobileControlTarget() is "fieldB" then
      answer "goodbye
   end if

end inputReturnKey
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Android Native Field Return Key

Post by Klaus »

Ah, mobilecontroltarget(), thank you!

Will keep this in mind if I ever get me a cellphone or tablet and start developing for the mobile platform :-)
Post Reply