Dismissing the keyboard
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Dismissing the keyboard
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
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
Targets: Mac, iOS
Re: Dismissing the keyboard
Hi mark...
Stack attached... look at the scripts of the fields
be well
Dixie
Stack attached... look at the scripts of the fields
be well
Dixie
- Attachments
-
- dismiss.livecode.zip
- (1.6 KiB) Downloaded 302 times
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Dismissing the keyboard
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,Dixie wrote:Hi mark...
Stack attached... look at the scripts of the fields
Dixie
-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Dismissing the keyboard
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.Dixie wrote:Hi mark...
Stack attached... look at the scripts of the fields
be well
Dixie
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
Targets: Mac, iOS
Re: Dismissing the keyboard
Hi Mark,
Kind regards
Bernd
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.I have a stack with 2 fields and a button. I don't want the keyboard to popup until the user selects a field
Kind regards
Bernd
Re: Dismissing the keyboard
Mark...
Bernd's solution is the correct one... Nice one Bernd!
be well
Dixie
Bernd's solution is the correct one... Nice one Bernd!
be well
Dixie
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Dismissing the keyboard
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)Dixie wrote:Mark...
Bernd's solution is the correct one... Nice one Bernd!
be well
Dixie
-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: Dismissing the keyboard
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
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
Re: Dismissing the keyboard
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
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
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Dismissing the keyboard
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.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?
-- 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
Targets: Mac, iOS
Re: Dismissing the keyboard
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
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
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Re: Dismissing the keyboard
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.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
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
Targets: Mac, iOS
Re: Dismissing the keyboard
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
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