Native controls - keyboard won't close

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Native controls - keyboard won't close

Post by cusingerBUSCw5N » Wed Oct 03, 2012 3:30 pm

I have had to use native controls to set up input fields to work on Android devices. I confirmed with technical support that this workaround was necessary because the LiveCode fields won't recognize the keyboards and only type in symbols or the first letter of a suggested word.

So, that is OK, but now my keyboard won't close - and of course, there is no close button on the keyboard.

I checked with tech support and they said:

"As for the focussing issue a workaround is to add an invisible, focusable field, with the lockText set to true and then focus on the invisible field before moving cards. This causes the keyboard to hide."

So, I did that. And the keyboard won't close.

First, I created a field and named it "invisible_field". I set clicked the "locked text" option on that field.
I kept the field visible for the time being and put "bob" in it to make sure the focus script was working.

Then, I put this code in my button to leave the card:

Code: Select all

if the environment is "mobile" then
  
      focus on fld "invisible_field"
      put "bob" into fld "invisible_field"
      end if
I succeeded in putting bob into my field - but the keyboard is still there.

Oh dear...

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Native controls - keyboard won't close

Post by cusingerBUSCw5N » Wed Oct 03, 2012 3:41 pm

Still a problem - I just realize that if something is "lock text" you shouldn't be able to put text in it...So I redid my invisible field to be a label - but still have the same result - the keyboard doesn't close.

so now my code is

Code: Select all

if the environment is "mobile" then
focus on fld "label field3"
      answer "say hi"
   end if
It says "say hi" so i know the focus part worked.... but the keyboard doesn't close

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Native controls - keyboard won't close

Post by jacque » Wed Oct 03, 2012 8:51 pm

You can put scripted text into a locked field, you just can't actually type into it.

I haven't seen the suggestion that RR gave you before. The usual way to dismiss the keyboard is to issue this command:

focus on nothing

See if that works. The default engine behavior is supposed to be that focusing on a field will display the keyboard, and focusing on nothing removes it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Native controls - keyboard won't close

Post by cusingerBUSCw5N » Thu Oct 04, 2012 12:32 am

Sorry I didn't mention it before

I tried "focus on nothing" - and it did nothing.

That's why I asked technical support for help.

I just tried adding "focus on nothing" after focusing on a hidden field.... and it still did nothing.

So then I tried putting a button that you click that says "focus on nothing" - and it eliminated the word suggestion line on the keyboard - but the keyboard remains.

The only way that it will release the keyboard is if I click a button that takes it to a email or a phone...and I hit cancel, the keyboard will go away. Unfortunately, both the email and phone functionality is part of the phone - not Livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Native controls - keyboard won't close

Post by jacque » Thu Oct 04, 2012 8:05 pm

I don't think it's possible to focus on an invisible field. You were on the right track to focus on the button.

This sounds suspiciously like a bug that was mentioned on the mailing list. It's been reported so the team will look at it soon. If I get a chance I'll take a look too. I have a couple of Android apps that work fine and the keyboard removes itself when the field focus changes, but they were built with a much earlier version of LiveCode. Something may have changed.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Native controls - keyboard won't close

Post by cusingerBUSCw5N » Fri Oct 05, 2012 8:42 pm

Here's the answer! Thanks to tech support. They made an error in the original solution - the lockText is supposed to be set to false

As for the focussing issue a workaround is to add an invisible, focusable field, with the lockText set to FALSE and then focus on the invisible field before moving cards. This causes the keyboard to hide

So here is the actual code that works:

Create a field - I called mine invisible_field
Set it to focusable with locktext off
Then create your native control, but add on closecard

Code: Select all

on opencard
 if the environment is "mobile" then
       put "multiline" into tControlType
mobileControlCreate tControlType, "myseventhInputField"
mobileControlSet "myseventhInputField", "visible", true 
mobileControlSet "myseventhInputField", "rect", "50,50,200,200"
end if
end opencard

on closecard
   if the environment is "mobile" then
   focus on field "invisible_field"
   mobileControlDelete myseventhInputField
end if
end closecard
It works! the keyboard closes :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Native controls - keyboard won't close

Post by jacque » Fri Oct 05, 2012 8:58 pm

Well I'll be. Didn't know you could focus on an invisible object. Thanks, and glad you got it working.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Android Deployment”