how i can have one date picker in iOS and Android?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Tue Jan 27, 2015 6:58 pm

Hi Klaus,

Thanks for your answer...:-)

I made this in my stack:

Code: Select all

on openCard
   if environment() = "mobile" then
      send "mouseUp" to btn "PickDate"
   end if
end openCard


on mouseUp
   if environment() = "mobile" then
      iphonePickDate "date"
      if the result <> "cancel" then
         put the result into resultPickDate
         put resultPickDate into line 1 of fld "Field3"
         convert resultPickDate to seconds
         put resultPickDate into line 2 of fld "Field3"
         convert resultPickDate to long date
         put resultPickDate into line 3 of fld "Field3"
      end if
   end if
end mouseUp
And i have one button "PickDate" and nothing in my script...

And i also tried to put this code in my card:

Code: Select all


on openCard
   if environment() = "mobile" then
      send "mouseUp" to btn "PickDate"
   end if
end openCard

And this in my button "PickDate"

Code: Select all

on mouseUp
   if environment() = "mobile" then
      iphonePickDate "date"
      if the result <> "cancel" then
         put the result into resultPickDate
         put resultPickDate into line 1 of fld "Field3"
         convert resultPickDate to seconds
         put resultPickDate into line 2 of fld "Field3"
         convert resultPickDate to long date
         put resultPickDate into line 3 of fld "Field3"
      end if
   end if
end mouseUp
And also it didn't work...:-(

So, apparently i didn't see what you mean...:-(
Even if i thought that i understood what you told me, but in the iPad i am not seeing nothing when i enter in the app...The screen is black for one second and then it goes out...:-(

Regards.

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

Re: how i can have one date picker in iOS and Android?

Post by Klaus » Tue Jan 27, 2015 7:29 pm

Hi aebki,

add a little delay, works sometimes:

Code: Select all

on openCard
   if environment() = "mobile" then
      send "mouseUp" to btn "PickDate" in 100 millisecs
   end if
end openCard
Best

Klaus

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Tue Jan 27, 2015 8:52 pm

Hi Klaus,

Thanks for your answer...:-)

Adding this delay it worked well!!! :-)

Regards

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Tue Jan 27, 2015 10:02 pm

Hi,

I tried to put a little bit of color to my date picker...:-)

So i decided to put one text field behind it filled in blue and with one red border...

But i have one problem...I need to make disappear the text field each time the date picker is disappearing too...

I tried with on mouseDown, on mouseLeave and on mouseRelease but i can't manage to make it disappear at the same time of the date picker...

For what i saw in the dictionary, i thought it should work with the on mouseRelease:

"Sent when the user releases the mouse outside the control that was clicked". But no, as i didn't manage...:-(

This is all my code:

Code: Select all

on openCard
   send "mouseUp" to btn "PickDate" in 100 millisecs
end openCard

on mouseUp
   if environment() = "mobile" then
      iphonePickDate "date"
      set the visible of field "FieldX" to true
      if the result <> "cancel" then
         put the result into resultPickDate
         put resultPickDate into line 1 of fld "Field3"
         convert resultPickDate to seconds
         put resultPickDate into line 2 of fld "Field3"
         convert resultPickDate to long date
         put resultPickDate into line 3 of fld "Field3"
      end if
   end if
end mouseUp

on mouseRelease
      set the visible of field "FieldX" to false
end mouseRelease
So there is another event to control this, and make it work appearing and disappearing with the date picker?

Regards.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Wed Jan 28, 2015 11:26 am

Hi,

It is me again...:-)

I continued trying this morning to find the correct event to make appear and disappear but i didn't manage...:-(

Is it possible to do what i am trying or simply not??? :-(

Regards

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

Re: how i can have one date picker in iOS and Android?

Post by Klaus » Wed Jan 28, 2015 1:31 pm

Hi aebki,

not sure I understand, but the ORDER of your commands is important.
Try this:

Code: Select all

on mouseUp

   ## I hate nested IF THEN ccases :-)
   if environment() <> "mobile" then
      exit mouseup
   end if
   
   ## Show fld right before the datapicker pops up!
   show fld "FieldX"

   ## Datepicker pops up NOW!
   iphonePickDate "date"
   ## Datepicker dispperas NOW!

   ## User clicked OK or CANCEL and datepicker has disappeared!
   hide fld "FieldX"
   put the result into resultPickDate
   
   ## See above :-)
   if resultPickDate = "cancel" then
      exit mouseup
   end if
   
   put resultPickDate into line 1 of fld "Field3"
   convert resultPickDate to seconds
   put resultPickDate into line 2 of fld "Field3"
   convert resultPickDate to long date
   put resultPickDate into line 3 of fld "Field3"   
end mouseUp
Hope I understood your problem correctly.


Best

Klaus

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Wed Jan 28, 2015 2:34 pm

Hi Klaus,

Thanks for your answer...:-)

Your code it solved quite my problem! :-)

So when i enter in the app on my iPad the first time is appearing the text field and then the date picker (so not in the same time...I WOULD LIKE ON THE SAME TIME)
I tried putting "lock / unlock screen" in different parts of the code but i didn't work...First in the mouseUp, then in the openCard and finally in both but always the text field is appearing first...:-(

And one the pick date is hide, if i press on the button "PickDate", then the text field and the date picker they are shown on the same time (AS I WANT),
but when it is hide the date picker first is disappearing the date picker and after the text field. ( I WOULD LIKE ON THE SAME TIME )

and the third thing is that if i press in the middle of the screen when i have no date picker, it shows the text field ( I WOULD LIKE IT WON'T SHOW NOTHING)

But if i press in the middle of the screen when the date picker is shown, both are disappearing, even if once again first disappears the date picker and then the text field...( I WOULD LIKE ON THE SAME TIME )

I don't know if i explained well my problem...:-(
I hope yes! :-)

Regards

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Wed Jan 28, 2015 2:36 pm

Hi,

It is me again...:-)

I forgot to let the code:

Code: Select all

on openCard
   lock screen
   send "mouseUp" to btn "PickDate" in 100 millisecs
   unlock screen
end openCard

on mouseUp
   
   ## I hate nested IF THEN ccases :-)
   if environment() <> "mobile" then
      exit mouseup
   end if
      
   ## Show fld right before the datapicker pops up!
   show fld "FieldX"
   
   ## Datepicker pops up NOW!
   iphonePickDate "date"
   ## Datepicker dispperas NOW!
   
   ## User clicked OK or CANCEL and datepicker has disappeared!
   lock screen   
   hide fld "FieldX"
   
   put the result into resultPickDate
   unlock screen   
   ## See above :-)
   if resultPickDate = "cancel" then
      exit mouseup
   end if
      
   put resultPickDate into line 1 of fld "Field3"
   convert resultPickDate to seconds
   put resultPickDate into line 2 of fld "Field3"
   convert resultPickDate to long date
   put resultPickDate into line 3 of fld "Field3"   
end mouseUp
Regards.

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

Re: how i can have one date picker in iOS and Android?

Post by Klaus » Wed Jan 28, 2015 3:20 pm

Hi aebki,

this does nothing:

Code: Select all

on openCard
   lock screen
   send "mouseUp" to btn "PickDate" in 100 millisecs
   unlock screen
end openCard
Do you know why? 8)

But I think that cannot be done, since the Datapicker is a separate and a non-LC process,
so it will first finish completely and you cannot "sync" this somehow with LC the way you want to.
Maybe I still did not understand your problem!?


Best

Klaus

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Wed Jan 28, 2015 3:30 pm

Hi Klaus,

Thanks for your answer...:-)

My first idea was to put the lock / unlock in the mouseUp, and it is what i did...:-)
But when it didn't "sync" is when i put it in the openCard, but was more 'playing lottery' than convinced it will work...:-)

I don't know the correct answer, but maybe is because of the delay???

And ok, now i think that i won't try more as there is no way to synchronize them...:-(

So yes, i think you understood me well and you gave me the answer!!! :-)
Even if this means that it won't work...:-(

Regards.

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

Re: how i can have one date picker in iOS and Android?

Post by Klaus » Wed Jan 28, 2015 4:12 pm

Hi aebki,

as I wrote earlier, see this PICKXXX as a MODAL dialog like the ASK and ANSWER dialog!
After you opended a modal window (or answer xxxx) the script will stop executing until the user closed that window!

The correct answer:
...
## Screen is locked NOW:
lock screen
send "mouseUp" to btn "PickDate" in 100 millisecs
## Screen is unlocked NOW, but the "mouseup" messages will only be delivered in 100 millisecs in the future!,
## so un-/locking the screen here is meaningless 8)
unlock screen
...


Best

Klaus

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Wed Jan 28, 2015 4:28 pm

Hi Klaus,

Thanks for your explanation!!! :-)

Regards.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Mon Feb 02, 2015 4:04 pm

Hi,

I used the date picker and is working fine...:-)

Then i tried to use one picker, but i have one problem with the result...:-(
In each number i press, when i want to see the value i pressed is added by ".1"...:-(
So if i press on the number "1" in the picker, the result i have in the field is "1.1", when i press "2", i have "2.1", etc...:-(

Why is appearing this ".1" and how i can make it disappear? I tried with trunc and with round but it is not working well...:-(
My pick is showing the numbers from 0 till 1000.

This is my code:

Code: Select all

on mouseUp
   if environment() = "mobile" then
      put "1" & cr into tNums
      repeat with i = 2 to 1000
         put i & cr after tNums
      end repeat
      mobilePick tNums,,,"picker"
      if the result <> "cancel" then
         put the result into NumSel
         --trunc(truncNumSel)
         put NumSel into fld "FldCant"
      end if
   end if
end mouseUp
Regards.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Mon Feb 02, 2015 7:29 pm

Hi,

In the code of my last post i didn't put it, but i also tried with the next code:

Code: Select all

put round(NumSel) into fld "FldCant"

Code: Select all

put trunc(NumSel) into fld "FldCant"
And i can't have the value without the ".1" in the field...:-(


Regards.

aebki
Posts: 126
Joined: Tue Jan 06, 2015 5:48 pm

Re: how i can have one date picker in iOS and Android?

Post by aebki » Mon Feb 02, 2015 8:13 pm

Hi,

It is me again...:-)

This code in 'desktop' is working:

Code: Select all

         put NumSel into fld "FldCant"
         put the text of fld "FldCant" into NumSel2
         put round(NumSel2,0) into fld "FldCant"
but in 'mobile' is not working...:-(

Code: Select all

on mouseUp
   if environment() = "mobile" then
      put "1" & cr into tNums
      repeat with i = 2 to 1000
         put i & cr after tNums
      end repeat
      mobilePick tNums,,,"picker"
      if the result <> "cancel" then
         put the result into NumSel
         put NumSel into fld "FldCant"
         put the text of fld "FldCant" into NumSel2
         put round(NumSel2,0) into fld "FldCant"
      end if
   end if
end mouseUp
Why is happening this??? Is it normal?

Regards

Post Reply