IOS Date Picker

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

IOS Date Picker

Post by arkstar » Sun Dec 11, 2011 4:24 pm

Hi all. I have been playing with the IOS date picker and have only been able to invoke it through a button.
I would like to invoke when the user taps on a field that would contain a date. Specifically I would like to use it with John Craig's wonderful Mobgui Native IOS text field.
I've tried enterInField, but that does not seem to work. Any thoughts or ideas?

Thanks

Rob
Rob Glassman
ArkStar

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: IOS Date Picker

Post by Klaus » Mon Dec 12, 2011 7:13 pm

Hi Rob,

I think the "openfield" message is what you are looking for!
Check the dictionary for more info.


Best

Klaus

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Tue Dec 13, 2011 1:30 pm

Thanks Klaus!

I guess I have 2 more questions:
1. The text field from Mobgui is actually a group. openControl doesn't seem to work.
2. I did get it working on a livecode text field but when you tap on the field, the date picker pops up, you tap on the date and it populates in the field, but then the standard keyboard pops up. How can I stop that from happening. I tried to invoke the focus on nothing but that doesn't seem to work either...

Thanks again for your response...

Rob
Rob Glassman
ArkStar

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: IOS Date Picker

Post by Klaus » Fri Dec 16, 2011 1:02 pm

Hi Bob,

sorry, I have no idea about MOBGui.

Maybe you should ask this in the dedicated MOBGui forum:
http://forums.runrev.com/phpBB2/viewforum.php?f=54


Best

Klaus

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Mon Dec 26, 2011 7:59 pm

Hi again Klaus,

Hope you had a good holiday. I had to tend to another project and I am just getting back to this one.
I made the 2 date fields into regular LC fields instead of mobgui fields. They are labeled:

Date In:
Date out:

The user taps on Date in and the date picker pops up. I choose the date then it jumps to the date out field wherethe date picker also pops up.I select that date, then the cursor stays at the end of the date and the standard IOS keyboard pops up, I can click on the screen and it goes away but I don't want the user to have to do this. I sent the focus on nothing command, but that doesn't work. I also tried to send a mouseDown to the background & card to see if that would make the keyboard disappear.

Do you have any ideas? Thanks!

Rob
Rob Glassman
ArkStar

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: IOS Date Picker

Post by sturgis » Mon Dec 26, 2011 8:23 pm

After all your date picking is done, 'focus on nothing'

Code: Select all

focus on nothing
arkstar wrote:Hi again Klaus,

Hope you had a good holiday. I had to tend to another project and I am just getting back to this one.
I made the 2 date fields into regular LC fields instead of mobgui fields. They are labeled:

Date In:
Date out:

The user taps on Date in and the date picker pops up. I choose the date then it jumps to the date out field wherethe date picker also pops up.I select that date, then the cursor stays at the end of the date and the standard IOS keyboard pops up, I can click on the screen and it goes away but I don't want the user to have to do this. I sent the focus on nothing command, but that doesn't work. I also tried to send a mouseDown to the background & card to see if that would make the keyboard disappear.

Do you have any ideas? Thanks!

Rob

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Mon Dec 26, 2011 9:01 pm

Hi Klaus,

Here is the code:

on openfield

iphonePickDate "date"
put the result into tDateResult
if tDateResult is 0 then
put "No Selection Made" into fld "dateout"
else

convert tDateResult from seconds to short date
put tDateResult into fld "dateout"
focus on nothing
end if

end openfield

It doesn't work. It does take the focus off the field, but the keyboard still shows

Thanks again
Rob Glassman
ArkStar

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: IOS Date Picker

Post by sturgis » Mon Dec 26, 2011 10:09 pm

Got a silly question but.. Since it appears the user doesn't actually need to be able to type into those fields anyway, how about setting the locktext of both fields to true, instead of open field use mouseup, and see if you can work around the problem that way. If the locktext is true the keyboard shouldn't pop up when you tap the field.

I can't test on ios since I don't own that package but tried it on Android and it seems to work.

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Tue Dec 27, 2011 1:29 am

I am going to try that, but here is something I did notice...

After you pick the date for the second field, "Date Out," the cursor does appear at the end of the text in the field.
I had the following :
on returnInField
focus on nothing
end returnInField

If I hit the return key, the keyboard did go away, but I have been unable to send a return via code and have it register.
I used:
put tDateResult & return into fld "dateout"
and
send return to fld "dateout"

but none of them worked. Any idea about that?

Will get back to you after I try your other suggestion...

Thanks
Rob
Rob Glassman
ArkStar

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: IOS Date Picker

Post by sturgis » Tue Dec 27, 2011 1:38 am

Without being able to test on IOS i'm about at the limit of my ideas.

If all that returninfield does is to focus on nothing it seems like it should work from your handler that inserts the dates.

Hmm. ok so maybe I do have another idea. You might try setting up a separate handler like so in the stack script

command stopfocus
focus on nothing
end stopfocus

and then in your handler that sets all the dates, as the very last line do something like

send "stopfocus" to this stack in 50 milliseconds

This way if there are any timing issues as far as whether the field is or is not still in focus, it should sidestep the problem and hopefully cause the keyboard to close properly.

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Tue Dec 27, 2011 1:41 am

Hi again Klaus,

Well, that worked! I have to tweak it a bit, but essentially it does work!
I would still like to know why send return didn't work though.
Thanks again for all your continuing help!

Rob

Happy New Year!
Rob Glassman
ArkStar

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: IOS Date Picker

Post by sturgis » Tue Dec 27, 2011 1:46 am

Edit: Oh, just read your other post a little closer. You said you were sending "return" to field "yourfield"
Since the message handler is actually named "returninfield" (the one that had your "focus on nothing") you would have to have a handler named return which could cause issues. Its already both a keyword and a constant so having a handler named that would probably be a bad idea.

send "returninfield" to field "yourfield" to get it to execute. You can't send a keypress directly using send (as far as I know). to make it work the other way you'd have to have a handler named return, and thats

Think Klaus has been busy the last couple days, but you're welcome. Did you try the send in time trick to see if it works also? (or which thing did you try that worked?)

arkstar
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 70
Joined: Mon Dec 21, 2009 1:51 am

Re: IOS Date Picker

Post by arkstar » Tue Dec 27, 2011 7:22 pm

Sorry Sturgis!

I didnt notice it was you but I thank you very much. Haven't triesd the send returninfield yet...
Your other fix works, but I will give it a try a little later!

Thanks again so much for your help!

Rob
Rob Glassman
ArkStar

Post Reply