is "mobile" on card

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 3:59 pm

Hi!
I'm developing my first app for mobile...after a great sweating, now I can test my app on my mobile device.

The problem I have is that i need to create a native text input but it didn't appear, so i inserted an answer popup to debug if the opencard script was running but it seems not.

On my first card i have this code:

Code: Select all

on openCard
    if the environment is "mobile" then
      answer "mobile" 
      --crea Numero Filiera
      mobileControlCreate "input","numeroFilieraMob"
      put the rect of button "numero" into AndroNumeroFiliera
      mobileControlSet "numeroFilieraMob","rect", "130,116,354,168"
      mobileControlSet "numeroFilieraMob","keyboardtype","numeric"
   end if
end openCard
No answer pop up and no mobile control created.

So i copied the code to the stack

Code: Select all

on openStack
   set the text of field "numero" to empty
     if the environment is "mobile" then
      answer "mobile" 
      --crea Numero Filiera
      mobileControlCreate "input","numeroFilieraMob"
      put the rect of button "numero" into AndroNumeroFiliera
      mobileControlSet "numeroFilieraMob","rect", "130,116,354,168"
      mobileControlSet "numeroFilieraMob","keyboardtype","numeric"
   end if
end openStack
Now the answer popup appear but still NO input control on my app.
What's wrong with my code?

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

Re: is "mobile" on card

Post by Klaus » Tue Mar 17, 2015 4:08 pm

Hi Geppo,

I think native controls are INVISIBLE per default,
so you also need to make the control visible after creating it!
...
mobileControlSet "numeroFilieraMob","keyboardtype","numeric"
mobileControlSet "numeroFilieraMob", "visible", true
...
And yes, that surely should go into the docs! 8)


Best

Klaus

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 4:14 pm

thank you so much :) It seems to work!
I'll be back on next issue ghgh

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 4:16 pm

oh no..another important thing...
If i want to add 1 to the number in the mobilecontrol pressing a button
Is it correct to use

Code: Select all

 add 1 to the field "numeroFilieraMob"
or "numerofilieraMob" is not consider as a field?

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

Re: is "mobile" on card

Post by Klaus » Tue Mar 17, 2015 4:25 pm

Hi Geppo,

1. the correct syntax to access LC controls is without THE:
...
## add 1 to the fld "xyz"
add 1 to fld "xyz"
...

2. No, you are right, a native text control is NOT a LC field and you need to access it in another way.
Basically you will need to:
...
put mobilecontrolget("numeroFilieraMob", "text") into tText
add 1 to tText
mobilecontrolset "numeroFilieraMob", "text", tText
## Not tested, but should work! 8)
...

Best

Klaus

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 4:29 pm

that's what i've done..but it seems not to work..

Code: Select all

     if the environment is "mobile" then
         put mobileControlGet ("numeroFilieraMob", "text") into lNumero
         add 1 to lNumero
         mobileControlSet "numeroFilieraMob","text",lNumero
      else       
         add 1 to the field "numero"
      end if

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 4:30 pm

oh no!...forget about last issue..
maybe the problem was an "if" before :)

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: is "mobile" on card

Post by gepponline » Tue Mar 17, 2015 4:47 pm

Here is the new issue....
The mobile control is always visible even if I change card.

So...
Is it better to HIDE the control when i change card and SHOW it when re-Open his card or I have to close and recreate it?

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

Re: is "mobile" on card

Post by Klaus » Tue Mar 17, 2015 5:11 pm

Yep, native controls "float" independently above the actual LC stack!
You can hide or delete it, its up to you :D

Thunder
Posts: 20
Joined: Thu Mar 12, 2015 1:52 pm

Re: is "mobile" on card

Post by Thunder » Tue Mar 17, 2015 9:30 pm

Thanks. Lots of good information here...

Post Reply