Dismissing the keyboard

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Dismissing the keyboard

Post by marksmithhfx » Tue Aug 02, 2011 2:34 am

Has anyone found a good way to dismiss the keyboard in iOS. I have a stack with 2 fields and a button. I don't want the keyboard to popup until the user selects a field, but I've not found a way to make that work.

On OSX I can say:

on opencard
focus on nothing
end opencard

and no field is selected. But that doesn't seem to work on iOS. The first field is still the focus, and the keyboard pops up.

What does work....

in any field if I say:

on returninfield
focus on nothing
end returninfield

Then when the user enters something and presses the enter key the keyboard will go away (and nothing is focused on). Unfortunately I can't get LC to mimic the same behaviour when it first opens the card.

Any suggestions?

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Dismissing the keyboard

Post by Dixie » Tue Aug 02, 2011 3:55 am

Hi mark...

Stack attached... look at the scripts of the fields

be well

Dixie
Attachments
dismiss.livecode.zip
(1.6 KiB) Downloaded 302 times

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Dismissing the keyboard

Post by marksmithhfx » Tue Aug 02, 2011 2:24 pm

Dixie wrote:Hi mark...

Stack attached... look at the scripts of the fields

Dixie
Thanks Dixie. This looks like a promising approach (but I've not actually got it working yet so I'll let you know the outcome later). I appreciate the quick response. Take care,

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Dismissing the keyboard

Post by marksmithhfx » Wed Aug 03, 2011 3:34 am

Dixie wrote:Hi mark...

Stack attached... look at the scripts of the fields

be well

Dixie
Hi Dixie, thanks for this... it certainly had the desired effect. There was a side effect that makes the solution less than ideal but that is not your fault. The first mouse click on the field just unlocks the field. It does not actually make it selectable (so it looks like nothing has happened). But the next click activates the field and the keyboard. Still, it is much much closer to the effect I was looking for so I will use it.

To runrev: the real solution here is for:

on opencard
focus on nothing

to work.

BTW I found I could get the same effect using only TraversalOn and not including the showfocusborder command (and enabling or disabling showfocusborder in the parameters seemed to have no effect)... thought I should pass it along. Thanks again

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dismissing the keyboard

Post by bn » Wed Aug 03, 2011 8:25 am

Hi Mark,
I have a stack with 2 fields and a button. I don't want the keyboard to popup until the user selects a field
what you could do is to set the traversalon of the button to true and set the layer of the button (in the inspector, size and position) to the lowest layer. You just send it back. This way the button will get the focus when the card opens but nothing happens and the fields will behave as you expect: touching them will show the keyboard. No scripting necessary.

Kind regards

Bernd

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Dismissing the keyboard

Post by Dixie » Wed Aug 03, 2011 9:10 am

Mark...

Bernd's solution is the correct one... Nice one Bernd!

be well

Dixie

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Dismissing the keyboard

Post by marksmithhfx » Thu Aug 04, 2011 4:36 am

Dixie wrote:Mark...

Bernd's solution is the correct one... Nice one Bernd!

be well

Dixie
Bernd, that looked like the **perfect** solution, and in fact works great in the IDE.... but, like the 'focus on nothing' command which does not work on iOS, this didn't either... the focus went straight to the field. Errggh (but thanks for thinking of a great suggestion)

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dismissing the keyboard

Post by bn » Thu Aug 04, 2011 7:39 am

Mark,

I did that on a real device and it worked. Could there be something else going on? Could you try this with just a bare bones stack, 1 card, 2 fields, 1 button?

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dismissing the keyboard

Post by bn » Thu Aug 04, 2011 9:08 am

Hi Mark,

I found the thread in the forum where this was discussed:
http://forums.runrev.com/phpBB2/viewtop ... ard#p30169

if your button is in a group then you would have to set the layer of the group to a lower number than the fields also. (again in the properties inspector for the group -> size and position)

Kind regards

Bernd

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Dismissing the keyboard

Post by marksmithhfx » Sat Aug 06, 2011 2:56 am

bn wrote:Mark,

I did that on a real device and it worked. Could there be something else going on? Could you try this with just a bare bones stack, 1 card, 2 fields, 1 button?
Hi Bernd, this might be a problem only in the iOS simulator then. I might start the process of getting my iPhone setup to receive stacks this weekend. I've attached the test stack.

-- Mark
Attachments
test.livecode.zip
(1.38 KiB) Downloaded 272 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dismissing the keyboard

Post by bn » Sat Aug 06, 2011 11:20 am

Hi Mark,

in your teststack you neither set the traversalon of the button, nor is the layer number lower than the fields layer number. This cant work.

Please try setting the layer number of the button to 1 and the traversalOn (or focus with keyboard) of the button to true.

Kind regards

Bernd

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Dismissing the keyboard

Post by marksmithhfx » Sat Aug 06, 2011 5:22 pm

bn wrote:Hi Mark,

in your teststack you neither set the traversalon of the button, nor is the layer number lower than the fields layer number. This cant work.

Please try setting the layer number of the button to 1 and the traversalOn (or focus with keyboard) of the button to true.

Kind regards

Bernd
Hi Bern, talk about (me) missing the point!! I thought you said to send the field to the back in your last post (my misunderstanding being that if it was in the back LC would see whatever was in the front first). I moved the button to the back (and set traversalon) and it now works properly.

So if I understand correctly, we are moving the button to the back so LC will see it BEFORE it sees the other field (ie. it scans from back to front?)

Thanks for being so patient with me.

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4166
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dismissing the keyboard

Post by bn » Sat Aug 06, 2011 10:21 pm

HI Mark,

glad it works for you now, without posting your stack I would neve have guessed. It is good to post scripts/stacks.

Kind regards

Bernd

Post Reply