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 » Thu Jul 19, 2018 4:14 am

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: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Android Native Field Return Key

Post by Klaus » Thu Jul 19, 2018 2:14 pm

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 » Fri Jul 20, 2018 2:20 am

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: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Android Native Field Return Key

Post by Klaus » Fri Jul 20, 2018 7:51 am

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 » Fri Jul 20, 2018 9:30 am

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: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Android Native Field Return Key

Post by Klaus » Fri Jul 20, 2018 10:52 am

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

Return to “Talking LiveCode”